• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Script + question

Status
Not open for further replies.
Level 17
Joined
Dec 11, 2014
Messages
2,004
Didn't know whether to post in T&S, or WEHZ, but I chose this one. If there's a problem, a mod can move it :)


-----------------------------

My first try on JASS is a system, a String Detection System (SDS).

I want to use it with my Custom Chat System (CCS) so that I can detect offensive language and change it with "*".

Now:
Id like to say the system itself.
JASS:
function SDS takes string s, string phrase returns nothing
 local integer i = 1
 local integer textlength = StringLength(s)
 local integer phraselength = StringLength(phrase)
 local string temps
  loop
   exitwhen i > phraselength
   set temps = SubString(phrase, i, i + textlength - 1)
    if temps == s then
     set udg_SDS_Num = udg_SDS_Num + 1
     set udg_SDS_1[udg_SDS_Num] = i
     set udg_SDS_2[udg_SDS_Num] = i + textlength - 1
    endif
  endloop
 set temps = null
endfunction


  1. My system is in map script.
    JNGP doesn't throw any errors.
    I love it.

Now here the problem comes:

When I used this for testing this, things worked fine, but everything after this Function call are not executed. Its like an empty return! Whats the problem?

  • Init Start Settings
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Trigger - Turn on Camera lock <gen>
      • Trigger - Turn on Clicking <gen>
      • Game - Display to (All players) the text: Type "-Music Normal...
      • Custom script: call SDS("fuck", "i need some fucking beer!")
      • For each (Integer Test_Integer) from 1 to SDS_Num, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: (String(SDS_Num))
          • Game - Display to (All players) the text: (String(SDS_1[Test_Integer]))
          • Game - Display to (All players) the text: (String(SDS_2[Test_Integer]))
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • Visibility - Create an initially Enabled visibility modifier for Player[(Integer A)] emitting Visibility across (Playable map area)
      • Custom script: call DestroyTrigger(GetTriggeringTrigger())
-Sorry if there is offensive language.

Now everything is fine, but the Text 1, 13, 16 isnt shown and THERE STILL IS FOG OF WAR. AND THE TEXT BEFORE FUNCTION CALL IS SHOWN.

Halp?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
I want to use it with my Custom Chat System (CCS) so that I can detect offensive language and change it with "*".
Most useful system ever... Forget actual gameplay, lets devote effort to remove peoples rights to freedom of speech instead.

When I used this for testing this, things worked fine, but everything after this Function call are not executed. Its like an empty return! Whats the problem?
Sounds like a thread crash.

This is a result of a op-limit thread crash because of an infinite loop block. You never increment the local variable "i" so the loop never exists. It does not freeze the game because the trigger thread crashes due to the op-limit being reached by the infinite loop.
JASS:
set i = i + 1

You also generate a ton of unique strings. Since strings lack garbage collection this can be considered a possible leak source. If a player was to spam long unique messages he could cause the game to perform so badly it becomes unplayable.
 
Level 17
Joined
Dec 11, 2014
Messages
2,004
Most useful system ever... Forget actual gameplay, lets devote effort to remove peoples rights to freedom of speech instead.


Sounds like a thread crash.

This is a result of a op-limit thread crash because of an infinite loop block. You never increment the local variable "i" so the loop never exists. It does not freeze the game because the trigger thread crashes due to the op-limit being reached by the infinite loop.
JASS:
set i = i + 1

You also generate a ton of unique strings. Since strings lack garbage collection this can be considered a possible leak source. If a player was to spam long unique messages he could cause the game to perform so badly it becomes unplayable.

I feel stupid... Thanks!
 
Status
Not open for further replies.
Top