Issue information

Issue ID
#5521
Status
Duplicate
Severity
None
Started
Hercules Elf Bot
Mar 28, 2012 2:19
Last Post
Hercules Elf Bot
Apr 18, 2012 9:37
Confirmation
Yes (0)
No (1)

Hercules Elf Bot - Mar 28, 2012 2:19

Originally posted by [b]MusiDex[/b]
Hello,

I am not shure if this is a bug, but when you have an if-query, containing something like:

[CODE]
if ( 0 && testfunc()) {}
if ( 1 || testfunc()) {}

[/CODE]

The "testfunc()" always will be called.
There are cases where this could be usefull, but I think in most cases it costs a lot of time, and should be changed.

Thanks :)

Hercules Elf Bot - Mar 28, 2012 2:31

Originally posted by [b]Brian[/b]
Updating status to: [b]Duplicate[/b] ([bug=4080])

http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=4080

This post has been edited by Brian on Mar 28, 2012 2:32

Hercules Elf Bot - Mar 28, 2012 3:27

Originally posted by [b]Lighta[/b]
Java also use full elevation so stating all langage may be a bit...
Anyway you talking about ea langage right because in C your report will be false as there many check using that shortcut to prevent segfault.

Hercules Elf Bot - Mar 28, 2012 11:52

Originally posted by [b]KeyWorld[/b]
I worked on some ways to optimize the script engine, I investigated for this in the past but it's really difficult to implement due to the way the script engine work.
Here what I understand (can be false, I didn't test).

If you start with a script like this:[code]5+2[/code]The operator is always at the end when reading the loaded script, that giving:[code]5 2 +[/code] The script engine read "5", then "2" and then "+" and do the operation "5+2".

So with a more complicate situation:[code]if ( 5 + 2 == 7 )[/code]That should return: [code]5 2 + 7 == ARG IF[/code]

So now, in case of a OR and AND condition:[code] mes "ok";
if ( .@debug && getgmlevel() < 30 ) {

}[/code]The result: [code]"ok" ARG mes .@debug getgmlevel < 30 && ARG if[/code]

Regarding of this, it's really complicate to understand where begin the condition and what should we skip or execute until you executed the condition.


--------------------------------------------------------------



So The easiest way to add it is to modify the if():

For this:[code] if ( .@debug && getgmlevel() < 30 ) {
dothis;
}[/code]

The current result is:[code] jump_zero( .@debug && getgmlevel() < 30, __IF_END );
dothis;
__IF_END:[/code]

And need to be change to:[code] jump_zero( .@debug, __IF_END );
jump_zero( getgmlevel() < 30, __IF_END );
dothis;
__IF_END:[/code]


But it will not fix the problem outside of a if or with ternary operator. So it sux, examples:[code]set .@can_enter, BaseLevel > 99 && SexAppeal()>300;
set .@var, isBad() ? query_sqlBadBoy() : query_sqlGoodBoy();[/code]




Hope it help, if someone is interesting to implement this thing.

Hercules Elf Bot - Mar 29, 2012 14:39

Originally posted by [b]DevilEvil[/b]
You could subdivide the if statement there (and use else-if). Code would be messy though.