wc3edit.net
https://forum.wc3edit.net/

Help fixing Typecasting Bug (function in desc)
http://forum.wc3edit.net/deprotection-cheating-f64/help-fixing-typecasting-bug-function-in-desc-t38606.html
Page 1 of 1

Author:  undeadjh [ June 20th, 2022, 8:48 am ]
Post subject:  Help fixing Typecasting Bug (function in desc)

Extracted .j file and used a simple regex to find consecutive returns. Feast your eyes on the problem:

Code:
function jt takes rect R returns unit
return R
return null
endfunction


Found some guides and helpful info (see below).
Not clear how to fix given examples taking and returning a unit and the above is taking and returning different variable types.

Please help :D

Thank you!!

Quote:
the way to fix it (IIRC):

Code:
function returnBug takes unit u returns unit
return u
return null
endfunction


This is an example for a return bug. It has 2 returns, 1 after the other.

Code:
function fix1 takes unit u returns unit
return u
endfunction
function returnBug takes unit u returns unit
call fix1(u)
return u
endfunction


Now those are 2 functions, each returning 1 value.

Though I can't understand how it works, it keeps the maps working.


If at all helpful below is where the return bug func is used. Would appear to be for pathing.
Spoiler:
Code:

function K1 takes nothing returns nothing
local integer L=KL(GetTriggeringTrigger())
local integer Id=jr(GetTriggerUnit())
local integer K0=GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
local group G
if GetStoredBoolean(jS(),"IsPathing"+I2S(Id),"UnitAttached")then
return
endif
if DistanceBetweenPoints(GetUnitLoc(jt(bn[L])),GetUnitLoc(GetTriggerUnit()))<DistanceBetweenPoints(GetUnitLoc(jt(bM[L])),GetUnitLoc(GetTriggerUnit()))then
if GetTerrainCliffLevelBJ(GetUnitLoc(GetTriggerUnit()))>GetTerrainCliffLevelBJ(GetUnitLoc(jt(bn[L])))then
return
endif
else
if GetTerrainCliffLevelBJ(GetUnitLoc(jt(bM[L])))>GetTerrainCliffLevelBJ(GetUnitLoc(jt(bn[L])))then
return
endif
endif
set G=It(GetOwningPlayer(GetTriggerUnit()))
if not IsUnitInGroup(GetTriggerUnit(),G)then
call StoreBoolean(jS(),"BeenDeselected"+I2S(Id),"UnitAttached",true)
call DisplayTimedTextToPlayer(Player(0),0,0,5,"not selected")
else
call StoreBoolean(jS(),"BeenDeselected"+I2S(Id),"UnitAttached",false)
call StoreBoolean(jS(),"CurrentlyPathing"+I2S(K0),"PlayerAttached",true)
endif
call GroupAddUnit(jU(GetStoredInteger(jS(),"PathingUnits"+I2S(K0),"PlayerAttached")),GetTriggerUnit())
call StoreBoolean(jS(),"IsPathing"+I2S(Id),"UnitAttached",true)
call ShowUnitHide(GetTriggerUnit())
call PauseUnit(GetTriggerUnit(),true)
call TriggerSleepAction(DistanceBetweenPoints(GetUnitLoc(jt(bn[L])),GetUnitLoc(jt(bM[L])))/500)
call PauseUnit(GetTriggerUnit(),false)
call SetUnitPathing(GetTriggerUnit(),false)
call TriggerSleepAction(0.5)
call ShowUnitShow(GetTriggerUnit())
if not GetStoredBoolean(jS(),"BeenDeselected"+I2S(Id),"UnitAttached")then
if GetStoredBoolean(jS(),"CurrentlyPathing"+I2S(K0),"PlayerAttached")then
call StoreBoolean(jS(),"CurrentlyPathing"+I2S(K0),"PlayerAttached",false)
call SelectUnitAddForPlayer(GetTriggerUnit(),Player(K0))
call TriggerSleepAction(0)
call StoreBoolean(jS(),"CurrentlyPathing"+I2S(K0),"PlayerAttached",true)
else
call SelectUnitAddForPlayer(GetTriggerUnit(),GetOwningPlayer(GetTriggerUnit()))
endif
endif
call GroupRemoveUnit(jU(GetStoredInteger(jS(),"PathingUnits"+I2S(K0),"PlayerAttached")),GetTriggerUnit())
if CountUnitsInGroup(jU(GetStoredInteger(jS(),"PathingUnits"+I2S(K0),"PlayerAttached")))<=0 then
call StoreBoolean(jS(),"CurrentlyPathing"+I2S(K0),"PlayerAttached",false)
endif
call FlushStoredBoolean(jS(),"BeenDeselected"+I2S(Id),"UnitAttached")
call TriggerSleepAction(0.2)
call SetUnitPathing(GetTriggerUnit(),true)
call FlushStoredBoolean(jS(),"IsPathing"+I2S(Id),"UnitAttached")
call DestroyGroup(G)
set G=null
endfunction

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/