• 🏆 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!

Fatal Error

This system was written long ago by Nestharus, but it was Grave-yarded because the CrashGame function wasn't working.
I made a fix and added a new function: EatRAM

JASS:
/**********************************************************
*
*   FatalError
*   v1.1.2.1
*   By Magtheridon96 (Special Thanks to Nestharus)
*
*   Uses:
*   -----
*
*       - Annoying a player. lol
*
*   API:
*   ----
*
*       - function ExitGame             takes nothing           returns nothing
*       - function ExitGameForPlayer    takes player p          returns nothing
*
*       - function FreezeGame           takes nothing           returns nothing
*       - function FreezeGameForPlayer  takes player p          returns nothing
*
*       - function CrashGame            takes nothing           returns nothing
*       - function CrashGameForPlayer   takes player p          returns nothing
*
*       - function DesyncGameForPlayer  takes player p          returns nothing
*
*       - function EatRAM               takes nothing           returns nothing
*           - This function can take up about 1 GB of memory in a minute.
*           - Use this on cheaters ;D
*           - This function may crash the game at one point.
*
*       - function StopThread          takes nothing           returns nothing
*
**********************************************************/
library FatalError
    
    globals
        private trigger Q = CreateTrigger()
    endglobals
    
    function ExitGame takes nothing returns nothing
        loop
            call ExecuteFunc("ExitGame")
        endloop
    endfunction
    
    function ExitGameForPlayer takes player p returns nothing
        if GetLocalPlayer()==p then
            call ExitGame()
        endif
    endfunction
    
    function FreezeGame takes nothing returns nothing
        loop
            call TriggerSyncReady()
            call ExecuteFunc("FreezeGame")
        endloop
    endfunction
    
    function FreezeGameForPlayer takes player p returns nothing
        if GetLocalPlayer()==p then
            call FreezeGame()
        endif
    endfunction
    
    function CrashGame takes nothing returns nothing
        call Player(-1)
    endfunction
    
    function CrashGameForPlayer takes player p returns nothing
        if GetLocalPlayer()==p then
            call CrashGame()
        endif
    endfunction
    
    function DesyncGameForPlayer takes player p returns nothing
        if GetLocalPlayer()==p then
            call CreateTrigger()
        endif
    endfunction
    
    private function Z takes nothing returns boolean
        local location l
        local integer i = 1000
        loop
            exitwhen 0==i
            set l = Location(0,0)
            set l = Location(0,0)
            set l = Location(0,0)
            set i=i-1
        endloop
        return false
    endfunction
    
    function EatRAM takes nothing returns boolean
        loop
            call TriggerEvaluate(Q)
        endloop
        return false
    endfunction
    
    function StopThread takes nothing returns nothing
        local integer i = 1/0
    endfunction
    
    private module Init
        private static method onInit takes nothing returns nothing
            call TriggerAddCondition(Q,Condition(function Z))
        endmethod
    endmodule
    private struct Inits extends array
        implement Init
    endstruct
endlibrary

I'm using this resource to make cheating players suffer >:p
 
Last edited:
Function EatRam will crash the game not just eat up the RAM, because you don't ever exit the first loop.

It depends :p
I tried it and forced my Warcraft to Exit after 1 GB was 'eaten' ^_^

What is 'Apiv'?

Permanent Invisibility just in case the unit is 'somehow visible' :p

FreezeGameForPlazer/CrashGameForPlayer should be wrappers for Freeze/CrashGame.

I just thought they would be more efficient in their current state :/
If it's due to Jass convention, I'll do it cause who even cares about the efficiency of functions like these xD
 
You can crash the game apparently by calling Player(<0 || >15). No need for some funny colour behaviour

Really? :eek:
I thought it just returns some null player :p
I'll try it out :)

So why do you even have the local boolean "e" in the loop trigger,
when it is always false?

Sorry about that ^_^
I'll remove it.

I also recommend using ExecuteFunc instead of TriggerEvaluate in
the function it evaluates, you obviously don't need efficiency there ;)

When I used ExecuteFunc, the game crashed after about 600 MB
With TriggerEvaluate, I was able to go above 1 GB
 
When I used ExecuteFunc, the game crashed after about 600 MB
With TriggerEvaluate, I was able to go above 1 GB

Fail ;)

Well ForForce(bj_FORCE_PLAYER[0], function Code) is supposed to be faster according to Troll-Brain, so I would give that a try as it avoids creating the conditionfunc, the boolexpr and the trigger ;)
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Fail ;)

Well ForForce(bj_FORCE_PLAYER[0], function Code) is supposed to be faster according to Troll-Brain, so I would give that a try as it avoids creating the conditionfunc, the boolexpr and the trigger ;)

I tested ForForce against .evaluate, which is not truly the same as directly TriggerEvaluate with a short variable name.
I wouldn't be suprised if with an efficient code if TriggerEvaluate is closed to ForForce or even faster.

But like i've already said ForForce has more cons than TriggerEvaluate, a better benchmark should be done. (you can use my cJass template in my benchmark main post)

Also Player() with positives integers doesn't seem to crash last time i tested it, even with something really high like 42 or 1337 (but negative does)
 
Last edited:
Level 17
Joined
Apr 27, 2008
Messages
2,455
Back on topic.

Mag, you could make StopThread returns an integer, this way you don't need any variable, or just use a local one (no need of inlining here) ...

EDIT : Hmm or inlining is needed ? Else it will be only the StopThread function which will be stopped ?
If inlining is mandatory you should clearly say it.

And btw isn't just equal to a return ?!


JASS:
function StopThread takes nothing returns nothing
        local integer i = 0/0
endfunction

JASS:
function StopThread takes nothing returns integer
        return 0/0
endfunction
 
Actually, division by 0 is an error that can terminate all functions in the function call stack, meaning an entire trigger/thread ;P

function a calls b
function b calls c
function c calls d
function d calls StopThread

Functions a, b, c and d will all terminate :)

StopThread is going to have to stay the way it is because this:

JASS:
function StopThread takes nothing returns integer
    return 0/0
endfunction

Would get inlined to nothing if you call it like this:

call StopThread()

It will only work if you call it like this:

set someInteger = StopThread()

The local variable one seems ugly :3
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
I think you should read again the jasshelper documentation about how the inlining occurs.
It wouldn't get inlined at all with a call StopThread() (and even if it inline you can still use a dummy double return)

And why the local is ugly, it's just a local variable definition (it hurts your speedfreak heart ?)

Don't take me wrong, i don't care about one less or more global variable, it seems just pointless here.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
This function will desync all players, look at this really.
JASS:
function DesyncGameForPlayer takes player p returns nothing
    if GetLocalPlayer()==p then
        call DestroyTrigger(CreateTrigger())
    endif
endfunction
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
No I didn't test it but... just think.

First, we all know this will desync
JASS:
if GetLocalPlayer() == somePlayer then
    call CreateTrigger()
endif

Lets look your function

JASS:
function DesyncGameForPlayer takes player p returns nothing
    if GetLocalPlayer()==p then
        //First function called inside local block is CreateTrigger, which 
        //will produce same result with above.
        call DestroyTrigger(CreateTrigger())
    endif
endfunction
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I didn't mean that.If something weird occurs, game sends disconnect to all players, so I don't even think there is a way to desync for specific player.Even there is a way, this isn't.
 
When something weird occurs, only the affected player gets disconnected.

I don't know what you're on about with this one. How is something localized to one player going to desync all players?

I'd like to see some proof to back up your claims, because it seems like empty words right now.

I am not trying to be rude here.
 
I have a new function:
It's in pseudo code :p

JASS:
private function ED takes nothing returns boolean
    local integer i = 1000
    call PreloadGenClear()
    call PreloadGenStart()
    loop
        call Preload("\")\n" + "8743598743598437259843275b4t7434t78425t7ygiufdh98vfy98d7fsd987fds987ds98f7ds98f7ds9yf98sdyfyfs9fys98ygds9uyfufshgiufhgiufdyugfidug9dfgu8u08fgu8fuidgufdoiugfioudfiugpoifdugifd89fd798gdfuifdugodfi7guofduoigfduyoigy9f8ygfiuygfdiuydsuyfse98fyeiuyrgiuerygeiurghdkgyeiyerogrey8eryoireyg89re7y8r0e98regy9ery9grhogifshguerhoierugo9er8ygre8iyregygre98yre9g8yre98gyer89yer9y9eryer98gy9rey9erksgjkfyiduholiyso8yg8oieuyg;p9ovieurvoieryvoireu874359874359843725s98f7ds9yf98sdyfyfs9fys98ygds9uyfufshgiufhgiufdyugdgufdoiugfioudfiugpoifdugifd89fd798gdfuifdugodfi7guofduoigfduyoigy9f8ygfiuygfdiuydsur8egyer98ygrey9er8gy98reygrey08grey98regy9ery9grhogifshguerhoierugo9er8ygre8iyregygre98yre9g8yre98gyer89yer9y9eryerholiyso8yg8oieuyg;p9ovieurvoieryvoireu435h94t8h24th2943ty493t8y49tyt98234yt94832yt4983yt94823y9t84yt94y98ty4298y39t4y8ty49uyto34yt9834yt43y9t34yt8y439pty439fiuseh9fhe9sfuewgf794wfg9wgrigegf8e6wge8wyryewg8yegyrvdtdvxy8ru0flolNestharusWasHerefojwe0f9u09e0r94903ru4j309jriwejf9ewjfoidsodisfyodfoudsfydsuoyfdsiuyfduisdyfiudsyfdsfds" + "\n(\"")
        set i=i-1
        exitwhen 0==i
    endloop
    call PreloadGenEnd("C:\\You_Suck.txt")
    return false
endfunction

function EatDisk takes nothing returns nothing
    loop
        call TriggerEvaluate(W)
    endloop
endfunction

function EatDiskForPlayer takes player p returns boolean
    if GetLocalPlayer()==p then
        call EatDisk()
    endif
    return false
endfunction

It's still experimental though :p
 
Last edited:
Level 17
Joined
Apr 27, 2008
Messages
2,455
Well, ofc "the weird thing" will happen if the desynchronised player was the host.
Some players will be kicked of the game, some will be in a new game with other players or not.

And since there is no accurate way to know which player is the host, you can't use it safely in a map (unless you assume the host is a bot or the player in the slot X, and that is actually the case : the first host has not already left and so one).

More, if you make the host lag or whatever else you will lead to a massive desync.

In an other side, a game with a lamer is not fun anyway :p
 
Level 17
Joined
Apr 3, 2010
Messages
1,101
Looks nice. But Eatram seems a bit useless considering that Wc3 has a max limit for ram it can take before it will stop responding and wont gain anymore.

After it hits 512mb ram it will stop responding usually and crash.

Most players would close Exe and restart :L

Then slowly it goes up while being allocated new ram. This may be different depending on PC.

A very nice function though.
 
Level 17
Joined
Apr 3, 2010
Messages
1,101
The highest i only ever got was 512. Before it crashed that was with over 10000 Acolytes o_O. 0.1 fps


But after it crashed(Stopped responding) the RAM usage slowly increased up to 900mb ram.

My point was after 512 ram usage it will just crash and wont be used anymore :L so it wont reach 1gb. But meh i dunno
 
I think this is better as it's less complex:

JASS:
/**********************************************************
*
*   FatalError
*   v1.1.2.1
*   By Magtheridon96 (Special Thanks to Nestharus)
*
*   Uses:
*   -----
*
*       - Annoying a player. lol
*
*   API:
*   ----
*
*       - function ExitGame             takes nothing           returns nothing
*       - function ExitGameForPlayer    takes player p          returns nothing
*
*       - function FreezeGame           takes nothing           returns nothing
*       - function FreezeGameForPlayer  takes player p          returns nothing
*
*       - function CrashGame            takes nothing           returns nothing
*       - function CrashGameForPlayer   takes player p          returns nothing
*
*       - function DesyncGameForPlayer  takes player p          returns nothing
*
*       - function EatRAM               takes nothing           returns nothing
*           - This function can take up about 1 GB of memory in a minute.
*           - Use this on cheaters ;D
*           - This function may crash the game at one point.
*
*       - function StopThread          takes nothing           returns nothing
*
**********************************************************/
library FatalError
    
    function ExitGame takes nothing returns nothing
        call ExecuteFunc("ExitGame")
    endfunction
    
    function ExitGameForPlayer takes player p returns nothing
        if GetLocalPlayer()==p then
            call ExitGame()
        endif
    endfunction
    
    function FreezeGame takes nothing returns nothing
        call TriggerSyncReady()
        call ExecuteFunc("FreezeGame")
    endfunction
    
    function FreezeGameForPlayer takes player p returns nothing
        if GetLocalPlayer()==p then
            call FreezeGame()
        endif
    endfunction
    
    function CrashGame takes nothing returns nothing
        call Player(-1)
    endfunction
    
    function CrashGameForPlayer takes player p returns nothing
        if GetLocalPlayer()==p then
            call CrashGame()
        endif
    endfunction
    
    function DesyncGameForPlayer takes player p returns nothing
        if GetLocalPlayer()==p then
            call CreateTrigger()
        endif
    endfunction
    
    function EatRAM takes nothing returns nothing
        local integer i = 2000
        loop
            set i = i - 1
            call Location(0, 0)
            call Location(0, 0)
            call Location(0, 0)
            exitwhen i == 0
        endloop
        call ForForce(GetForceOfPlayer(GetLocalPlayer()), function EatRAM)
    endfunction
    
    function StopThread takes nothing returns nothing
        local integer i = 1/0
    endfunction
    
endlibrary

Either way I think this is a really dangerous library because it can be easily misused in the hands of idiots. For example someone might pick on a newbie.

I might end up having to graveyard this just for better sense.

The function that makes the most sense is this:

JASS:
function CrashGame takes player p returns boolean
    return GetLocalPlayer() == p and p == Player(-1)
endfunction
 
If you've tested each function, I'll gladly change the code.

But I think the idea behind this library is fundamentally flawed.

:c

JASS:
function CrashGame takes player p returns boolean
    return GetLocalPlayer() == p and p == Player(-1)
endfunction
This would fail if someone did this:
call CrashGame() // It gets inlined, but to what?
 
It would not get inlined because you have to have a player argument and the argument is referenced twice.

JassHelper also doesn't inline "call X()" when X has a return value.

I removed the loops from your other functions because you have to think about recursion - if you keep re-evaluating the same script repeatedly then the loop will never iterate more than once, it will just keep going back to the top of the function again and again. The loop is not necessary.
 
Top