The Return Bug problem

NineClick

New Member
Reaction score
11
does anyone know how to remake this function? it uses return bug. i don't want to use hashtable so i'm still using game cache.

JASS:
function TheUnit takes string S1,string S2 returns unit
    return GetStoredInteger(udg_Cache,S1,S2)
    return null
endfunction


i'm ok with the return integer. my problem now is when returning a unit, group, etc. pls help. thanks. +rep. :thup:
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Change it to hashtable.

If you don't know about it, post your storage system here.
So that it can be fixed asap.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
Use Hashtables. They are faster anyways and you can directly get the Unit out of it without the need of a return bug function.

The functions for hashtables are almost the same as with GCs, so there's no point to stick to GCs.

JASS:

call LoadUnitHandle(hashname, I1, I2)
call SaveUnitHandle(hashname, I1, I2, YourUnit)
call FlushChildHashtable(hashname, I1)
call RemoveSavedHandle(hashname, I1, I2)
call HaveSavedHandle(hashname, I1, I2)

Just switch your String based storing to integer based and you are done.
 

NineClick

New Member
Reaction score
11
i dunno how to use hashtable,still not familiar with it. i'm currently working on it though. ... how do you change my code without using hashtable? its ok if its going to be a two separate functions. because i need that code to call a unit using a string. pls help. tnx.
 

NineClick

New Member
Reaction score
11
ok .. so here's my code, from storing to getting the data. anyone?.. pls help.

The functions below are Custom Code Script: (These are the codes that need to be changed.)

JASS:
function H2I takes handle H1 returns integer
    return GetHandleId(H1)
endfunction

function H2Tx takes handle H2 returns string
    return I2S(H2I(H2))
endfunction

function SetHandle takes string table,string key,handle data returns nothing
    call StoreInteger(udg_Cache,table,key,H2I(data))
endfunction

function GetUnit takes string S1,string S2 returns unit
    return GetStoredInteger(udg_Cache,S1,S2)
    return null
endfunction

function GetGroup takes string S3,string S4 returns group
    return GetStoredInteger(udg_Cache,S3,S4)
    return null
endfunction



The functions below are how i store and get the data:

This function gets the data:
JASS:
function Fight takes unit UN1,unit UN2 returns nothing
    local string STN=H2Tx(UN1)
    local group LKH=GetGroup(STN,"Defenders") //this gets the group stored.
    local unit LKG=GetUnit(STN,"Attacker")//this gets the unit stored.
    if(LKG!=pKg)and(LKG!=null)then
	call Amfufu(LKH)
    ///... the rest are some codes.
endfunction


These functions store the data:
JASS:
function Attack takes nothing returns nothing
    call Fight(GetOrderTargetUnit(),GetTriggerUnit())
endfunction

function Unit takes unit UN returns nothing
    local group GRP
    local trigger TRG
    local string STR=H2Tx(UN)
    set GRP=CreateGroup()
    call SetHandle(STR,"Defenders",GRP)
    set TRG=CreateTrigger()
    call SetHandle(STR,"OnAttackOrder",TRG)
    call TriggerRegisterUnitEvent(TRG,UN,EVENT_UNIT_ISSUED_TARGET_ORDER)
    call TriggerAddAction(TRG,function Attack)
endfunction

function Defend_Action takes nothing returns nothing
    call Unit(GetTriggerUnit())
endfunction

function InitTrig_Defend takes nothing returns nothing
    set gg_trg_Defend =CreateTrigger()
    call TriggerRegisterEnterRectSimple(gg_trg_Defend,GetWorldBounds())
    call TriggerAddAction(gg_trg_Defend ,function Defend_Action)
endfunction
 

Artificial

Without Intelligence
Reaction score
326
Create a hashtable variable called Hashtable, and initialize it with a new hashtable. Then just replace your SetHandle, GetUnit, and GetGroup with these:

JASS:

function SetHandle takes string table, string key, agent data returns nothing
    call SaveAgentHandle(udg_Hashtable, StringHash(table), StringHash(key), data)
endfunction

function GetUnit takes string S1, string S2 returns unit
    return LoadUnitHandle(udg_Hashtable, StringHash(S1), StringHash(S2))
endfunction

function GetGroup takes string S3, string S4 returns group
    return LoadGroupHandle(udg_Hashtable, StringHash(S3), StringHash(S4))
endfunction


Should work, me thinks. ^_^
 

NineClick

New Member
Reaction score
11
still not working. .. anyone?.. please help with my code. +rep to those who can help. thanks.
 

Aedes

Member
Reaction score
8
Your code looks familiar. Hmmm. Anyways, return bug doesn't work anymore in 1.24b patch so you really have to use Hashtable. Hashtable is a better data storage than Game Cache. Well, for your code, it looks to me that your "SetHandle" function is the one converting the unit and group to integer and it stores it to your game cache (as integer of course). In this case, why don't you create an individual storage for your unit and group. Well at least you can get it or return it as a group and unit (and not as an integer), and still use the return bug.

For your unit and group storage:

JASS:
function SetGroup takes string table,string key,group grp returns nothing
    call SaveGroupHandle(udg_Hashtable,StringHash(table),StringHash(key),grp)
endfunction

function SetUnit takes string table,string key,unit unt returns nothing
    call SaveUnitHandle(udg_Hashtable,StringHash(table),StringHash(key),unt)
endfunction


To get the stored group and unit:

JASS:
function GetUnit takes string S1,string S2 returns unit
    return LoadUnitHandle(udg_Hashtable,S1,S2)
    return null
endfunction

function GetGroup takes string S3,string S4 returns group
    return LoadGroupHandle(udg_Hashtable,S3,S4)
    return null
endfunction


The H2Ix and H2Tx functions are fine. Do not use your SetHandle anymore. Ok.
 

NineClick

New Member
Reaction score
11
..wow. tnx dude. you gave me an idea on what to do. nwei, i'll try your code. tnx again. +rep! :thup:
 

Jesus4Lyf

Good Idea™
Reaction score
397
>Hmmm. Anyways, return bug doesn't work anymore in 1.24b patch
Sure it does.
JASS:
function ReturnI takes integer i returns integer
return i
endfunction
function NothingH takes Nothing returns handle
if false then
return null
endif
endfunction
function ReturnH takes handle h returns handle
return h
endfunction
function I2H takes integer i returns handle
call ReturnI(i)
return ReturnH(NothingH())
endfunction

Zomg. It are I2H. :D
(Don't use it. It are for me only. :p)
 

Aedes

Member
Reaction score
8
>Hmmm. Anyways, return bug doesn't work anymore in 1.24b patch
Sure it does.

It doesn't? .. But its ok to have two returns. Right? I thought it's working because it doesn't have any errors everytime I save it in WE. So if doesn't, then which of the two returns won't work?
 

Jesus4Lyf

Good Idea™
Reaction score
397
>So if doesn't, then which of the two returns won't work?
Having two returns has little or nothing to do with the return bug.

If you return twice, the first return will stop the function.

The return bug is about typecasting. There is a new(er) version of the return bug which I posted, just because it is still around. :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top