Branks
01-12-2005, 01:11 PM
hey, ive been breaking the emu source code again with the goal of some of it atleast being useable for everyone, currently im attempting to make the AA system a bit more flexable and swarm pets as well, my real goal is to master the language though by indirectly learning from whats in the source. since i know eq, i can see the goal of it and learn from seeing how its accomplished, however theres a lot of "why's" i cant understand so rather than searching the net and finding contradicting opinions on a lot of things im just going to ask here so anyone more experienced can comment or explain.
complier optimization with loop unrolling, ive read its best to try always useing variables which remain the same each function call in order for the compiler to be able to unroll the loop, however it seems this isnt often considered and i was curious if anyone knows if the reward of doing this is actually worth the little extra effort.
accessing multi dimensional arrays, ive heard this is slow enough to be avoided when its possible, however some situations such as Mob::SpellEffect which various cases within, will need to access the array which holds AA spell IDs and recourses of AA spell Ids, would it be better to store these commonly checked spell IDs in global variables? instead of accessing the array each pass?
on the note of the spell IDs above, if i were to declare a static integer to retrieve the spell ID from the array, to prevent it from being accessed every pass, since SpellEffect() is a method of the mob class would these static intergers be created for every instance of Mob() or would it be file scope of sorts? im pretty sure the answer is they would be created for every instance however lack of experience makes me curious and im unsure of any method in order to test this.
Global pointers which are later newed, are these deleted during shutdown?
Inline and virtual functions, i believe there is a bit of extra work thats done when calling a virtual function since it needs to check the scope of the function, so... well the situation is, i was considering removing GetAA() which is virtual, entirely from Mob() scope in order to inline it in Client(), would this be desireable at the cost of a 5 or so checks to IsClient()/CastToClient() in mob scope where AA Checks are required?
Limiting functions/methods, odd one but where do most of you draw the line on creating new ones, such as would you consider 2 large switches to be justifiable for the overhead of a function call? or where exatly is the commonly considered "ok" line between inline-able and a needed function/method when avoidable?
functions pointers, do they double the overhead for function calls, in that is it actually 2 functions which are called when used in case of a method? not sure i worded that one correctly so basicly im curious if they should be avoided, currently my method of handling the special attacks etc of some swarm pets was to create a method which the AI Loop calls, which calls a function pointer which is set during pet creation, would a switch be more desirable instead?
anyway, i know some of this is probably avaliable around the net however as mentioned theres a lot of conflicting opinions/information around so i assumed id ask the people whom may be useing any progress i eventually make, and i assume these are pretty common questions most people in my position may have so, cant hurt to have it here i guess, anyway thanks for your time.
complier optimization with loop unrolling, ive read its best to try always useing variables which remain the same each function call in order for the compiler to be able to unroll the loop, however it seems this isnt often considered and i was curious if anyone knows if the reward of doing this is actually worth the little extra effort.
accessing multi dimensional arrays, ive heard this is slow enough to be avoided when its possible, however some situations such as Mob::SpellEffect which various cases within, will need to access the array which holds AA spell IDs and recourses of AA spell Ids, would it be better to store these commonly checked spell IDs in global variables? instead of accessing the array each pass?
on the note of the spell IDs above, if i were to declare a static integer to retrieve the spell ID from the array, to prevent it from being accessed every pass, since SpellEffect() is a method of the mob class would these static intergers be created for every instance of Mob() or would it be file scope of sorts? im pretty sure the answer is they would be created for every instance however lack of experience makes me curious and im unsure of any method in order to test this.
Global pointers which are later newed, are these deleted during shutdown?
Inline and virtual functions, i believe there is a bit of extra work thats done when calling a virtual function since it needs to check the scope of the function, so... well the situation is, i was considering removing GetAA() which is virtual, entirely from Mob() scope in order to inline it in Client(), would this be desireable at the cost of a 5 or so checks to IsClient()/CastToClient() in mob scope where AA Checks are required?
Limiting functions/methods, odd one but where do most of you draw the line on creating new ones, such as would you consider 2 large switches to be justifiable for the overhead of a function call? or where exatly is the commonly considered "ok" line between inline-able and a needed function/method when avoidable?
functions pointers, do they double the overhead for function calls, in that is it actually 2 functions which are called when used in case of a method? not sure i worded that one correctly so basicly im curious if they should be avoided, currently my method of handling the special attacks etc of some swarm pets was to create a method which the AI Loop calls, which calls a function pointer which is set during pet creation, would a switch be more desirable instead?
anyway, i know some of this is probably avaliable around the net however as mentioned theres a lot of conflicting opinions/information around so i assumed id ask the people whom may be useing any progress i eventually make, and i assume these are pretty common questions most people in my position may have so, cant hurt to have it here i guess, anyway thanks for your time.