Do you have to nullify a "handle" variable, too?

N-a-z-g-u-l

New Member
Reaction score
30
i was just wondering if you have to nullify a variable of type "handle", too... or if you have to do it only with all types extending handle...

because if you have to nullify them, then you could create a quite safe system, but not specific for only one handle type...
 

The_Kingpin

Member (Who are you and why should I care?)
Reaction score
41
All destructables, units, special effects, lightnings, etc. are handles.

Handles are not destructables, units, special effects, lightnings, etc.

JASS:
function test takes handle h returns nothing


Can take destructables, units, etc.
JASS:
function test2 takes destructable d returns nothing


CANNOT take a handle.

You also cannot compare handles to destructables, units etc.

What system do you think of making?
 

SFilip

Gone but not forgotten
Reaction score
634
Yes, you need to null handles too.
 

N-a-z-g-u-l

New Member
Reaction score
30
ok thanks...

and what kind of system: ive made a system (mostly for myself) which returns a valid array index from a timer given to it, can get the array index back, if it knows the timer, and clears the array index... basically working like ABC

now i wanted to attach things to triggers, too, and i wondered if it was possible to replace all timer variables with handle variables without loosing the safety having the variable in a global variable... so no other new handle will overwrite that id...
and if you have to nullify handle-type variables, too, that means, that if you have still saved them somewhere in a variable, their handle id wont be given to a new object

for those interested in the system:
for the new version ive stolen one idea of ABC: it does not begin looping at front of the array, if it reaches index 8192... this makes the loop faster, and because i only give indexes up to 8100, there shouldnt be any problems with that...
(i made that one in notepad, so it does not have to be free of mistakes)

and note that this is nothing everyone has to use because it is uber fast, safe, easy and so on... it just fits my needs
JASS:
globals
	handle array udg_AV_Handles
endglobals

function H2I takes handle h returns integer
	return h
	return 0
endfunction

function CreateHandleId takes handle h returns integer
	local integer i=H2I(h)
	set i=i-(i/8100)*8100
	loop
		exitwhen udg_AV_Handles<i>==null
		set i=i+1
	endloop
	set udg_AV_Handles<i>=h
	return i
endfunction

function GetHandleId takes handle h returns integer
	local integer i=H2I(h)
	set i=i-(i/8100)*8100
	loop
		exitwhen udg_AV_Handles<i>==h
		set i=i+1
	endloop
	return i
endfunction

function DestroyHandleId takes integer i returns nothing
	set udg_AV_Handles<i>=null
endfunction</i></i></i></i>


and you know CSSafety? i liked that system, too, made my own then, and it looked mostly like vexorians version, but without CSData and without vJass... (the overall idea, the idea of destroying timers if the stack is full and function names are stolen)
this is meant as an example of scripts i create for myself, because i dont use vjass and dont really trust in foreign code^^ (well, i use the map optimizer nevertheless :p btw, thanks for it)
JASS:
globals
	timer array udg_TimerStack
	integer udg_TimerStackN
endglobals

function NewTimer takes nothing returns timer
	if udg_TimerStackN==0 then
		set udg_TimerStack[0]=CreateTimer()
		return udg_TimerStack[0]
	endif
	set udg_TimerStackN=udg_TimerStackN-1
	return udg_TimerStack[udg_TimerStackN]
endfunction

function ReleaseTimer takes timer t returns nothing
	call PauseTimer(t)
	if udg_TimerStackN==8191 then
		call DestroyTimer(t)
	else
		set udg_TimerStack[udg_TimerStackN]=t
		set udg_TimerStackN=udg_TimerStackN+1
	endif
endfunction



EDIT: seems like i have to use vJass now, to create that global handle array...^^ ill give it another try
 

Cohadar

master of fugue
Reaction score
209
:cool: I'm observing.

And to answer your question, storing stuff in raw handles is safe
(in the sense that it preserves reference counts)
 

N-a-z-g-u-l

New Member
Reaction score
30
note that its for the new version only ;) and the basic idea was developed by myself... btw, i dont understand your hashing, so i could not use that...^^ well, i know it uses integer overflow, but because integers are also negative numbers i couldnt get a "modulo" to work... i then stopped optimizing it that much, because its already really fast enough^^
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
well you could always create a function which imitates the XOR operator
 

Technomancer

New Member
Reaction score
14
The difference in speed after compile with native java programmed operators is a few times faster than doing it in vJass so scripting it manually to improve speed is kind of moot.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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 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

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top