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.
  • 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 The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top