[Include] Sort multi-dimensional arrays (enums supported)
#41

May I see the code that does the sorting, and related enum declarations?
Reply
#42

Thank you, Slice! When I saw this topic, born many ideas. ^^
Reply
#43

Quote:
Originally Posted by Slice
Посмотреть сообщение
May I see the code that does the sorting, and related enum declarations?
I didn't even add it yet, I only added the include. Just as soon as I add it to the gamemode it can't compile:

Quote:

#include <md-sort>

Reply
#44

Err... you probably messed up the newlines somehow - try just copying the contents here then pasting it into md-sort.inc.
Reply
#45

Ok, kinda stupid but seems it was a download issue indeed. Retried it in a differnet browser and now it works. How stupid is that :P

Thanks for your help!
Reply
#46

Let me guess, you used Internet Explorer?
Reply
#47

No, Firefox was the failing browser. In Chrome it worked fine.
Reply
#48

I want to sort a single dimensional array which contains player kills, should I use the custom comparator ?
Reply
#49

Use this: http://forum.sa-mp.com/showpost.php?...postcount=3437
Reply
#50

Slice, i found a problem in your include.
I've looked in the script report (generated with -r)

Код:
		<member name="M:SortArrayUsingComparator_QS" syntax="SortArrayUsingComparator_QS(array, func, left, right)">
			<stacksize value="10"/>
			<referrer name="SortArrayUsingComparator_Entry"/>
			<referrer name="SortArrayUsingComparator_QS"/>
			<dependency name="ExchangeArraySlots"/>
			<param name="array">
			</param>
			<param name="func">
			</param>
			<param name="left">
			</param>
			<param name="right">
			</param>
		</member>
Код:
		<member name="M:SortArrayUsingCompInto_QS" syntax="SortArrayUsingCompInto_QS(array, results[], func, left, right)">
			<stacksize value="11"/>
			<referrer name="SortArrayUsingCompInto_Entry"/>
			<referrer name="SortArrayUsingCompInto_QS"/>
			<param name="array">
			</param>
			<param name="results">
				<paraminfo> [] </paraminfo>
			</param>
			<param name="func">
			</param>
			<param name="left">
			</param>
			<param name="right">
			</param>
		</member>
As you can see, it causes recursion.
Could you please fix that?
Reply
#51

What ****** said. Additionally, this makes Pawn unable to determine the maximum stack/heap size.

To assure you won't run into issues, you should the stack/heap size with the "#pragma dynamic" directive.
Reply
#52

Oh, didn't know about that QuickSort. I knew, that bounded recursion is ok but the "unknown, due to recursion" message is rather ugly.

Already using "#pragma dynamic", hope 8000 is enough for sorting few (small) arrays + the for other script parts.
Reply
#53

Would be very awesome ****** - maybe (if Slice agrees) you could add md-sort to YSI. Would be a nice enlargement for YSI.
Reply
#54

I mean this include. Anyway, what about making this include GPL?
Reply
#55

No no i mean making md-sort GPL and then porting the structure.

Btw, why isn't it possible to use "goto"?
Reply
#56

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
Programie: what are the actual errors/warnings? You can set the compiler to ignore certain warnings but you should fix them instead of hide from them!
They are all "tag mismatch" warnings.

Код:
X:\GitHub\SAMPRacing\includes\grgserver\functions\LoadCommands.inc(49) : warning 229: index tag mismatch (symbol "g_commands")
X:\GitHub\SAMPRacing\includes\grgserver\functions\LoadCommands.inc(49) : warning 213: tag mismatch
X:\GitHub\SAMPRacing\includes\grgserver\functions\LoadCommands.inc(49) : warning 213: tag mismatch
Line 49 of LoadCommands.inc:

Код:
SortDeepArray(g_commands, String:E_COMMAND_NAME);
Reply
#57

I am trying to sort an enum by two columns using the 'SortArrayUsingComparator()' function, but something is not right.

I put the test code to pastebin here:

http://pastebin.com/iEjKvGx4

The OnScriptInit stops executing when it reaches the sort function. Did I do something wrong with the comparator? or what?

thanks

EDIT: looks like I made an infinite loop somehow. I get this message on "function crash"

Код:
Script[gamemodes/comparator2.amx]: Run time error 3: "Stack/heap collision (insufficient stack size)
Reply
#58

For some reason, this include crashes my compiler, any reason why?
Reply
#59

I'm using the Pawno compiler. It just seems to crash when I include the script.
Reply
#60

Last night.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)