Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
<C> ASSS Colors/Say/Voice Module
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic Printable version
 View previous topic  <C> ASSS Flags Module Post :: Post Continuum Log Viewer  View next topic  
Author Message
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Fri Apr 02, 2010 4:37 pm    Post subject: Reply to topic Reply with quote

colors module has undergone a final redesign, and will most likely not be altered in the future.

if the file timestamp on your files is older than this post's timestamp, your version is outdated. grab a new copy.

there is really no reason why any zone should not have this module, all the cool kids have it...

:)
_________________
SSC Distension Owner
SSCU Trench Wars Developer
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Thu Apr 29, 2010 1:11 am    Post subject: Reply to topic Reply with quote

fixed bug in new logic that sent arena messages to zone.
files updated.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Wed Jun 02, 2010 7:23 am    Post subject: Reply to topic Reply with quote

updated interface.
should be slightly faster, and now you arent forced to use the color constants, even if theres no real reason not to :P
files updated.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sun Jun 27, 2010 2:46 pm    Post subject: Reply to topic Reply with quote

What's going here? Your if/else statements do not work as the indenting would lead you to believe...
Code: Show/Hide
         if(mode == MODE_ZONE) LLAdd(&playerlist,pp);
         else
         {
            if(mode == MODE_ARENA) if(pp->arena == a) LLAdd(&playerlist,pp);
            else
            {
               if(mode == MODE_FREQ) if(pp->arena == a) if(pp->pkt.freq == freq) LLAdd(&playerlist,pp);
               else return; //wtf?
            }
         }


Correct indenting:
Code: Show/Hide

         if(mode == MODE_ZONE)
            LLAdd(&playerlist,pp);
         else
         {
            if(mode == MODE_ARENA)
               if(pp->arena == a)
                  LLAdd(&playerlist,pp);
               else
               {
                  if(mode == MODE_FREQ)
                     if(pp->arena == a)
                        if(pp->pkt.freq == freq)
                           LLAdd(&playerlist,pp);
                        else return; //wtf?
               }
         }


I don't know if that's how you intended it to work, but your indenting makes me believe otherwise...
Having 3 if's on the same line generally is a bad idea tongue.gif
_________________
(Insert a bunch of dead links here)
Back to top
View users profile Send private message Add User to Ignore List
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Mon Jun 28, 2010 3:52 pm    Post subject: Reply to topic Reply with quote

i think it was because i was testing something or other, and forgot to fix it...
in any case, its fixed.
files updated.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Mon Jun 28, 2010 8:01 pm    Post subject: Reply to topic Reply with quote

Another small thing I noticed... your module logs messages using the ERROR tag when it loads and unloads correctly, you might want to change that to Information
Back to top
View users profile Send private message Add User to Ignore List
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Tue Jun 29, 2010 3:48 am    Post subject: Reply to topic Reply with quote

all my modules do

INFO level messages are by default not sent to chat
when the zone crashes because someone attached a module to a different arena, id want to know
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sun Jul 04, 2010 12:33 am    Post subject: Reply to topic Reply with quote

Suggestion: Would be nice to be able to use printf style format with the ColorA, ColorP, etc. functions
Back to top
View users profile Send private message Add User to Ignore List
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Mon Jul 05, 2010 9:10 pm    Post subject: Reply to topic Reply with quote

I modified the code so the interface handles printf style formatting.

I also added interface functions to send colored messages with sounds biggrin.gif


Note that I stripped off the code of the Voice module in there, because I was lacking some constants, presumably in the xchat module, and I didn't want to bother with that... So do what you want with it tongue.gif

There are a few minor changes here and there I did while skimming through your code, mostly in code formatting (i.e. a switch (params[0]) instead of if...else if... chain).




colors_sama.zip - 18.54 KB
File downloaded or viewed 236 time(s)
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Mon Jul 05, 2010 10:09 pm    Post subject: Reply to topic Reply with quote

In matters of style, an if-else chain is generally preferred over switch statements. See the Java style for an example. The if statements are more flexible, and therefore easier to expand in the future, and of course the basic form generates the same machine code.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Mon Jul 05, 2010 11:43 pm    Post subject: Reply to topic Reply with quote

Well it depends what is subject to change... if the input is subject to change, your if else if chain will be less flexible, since you'll need to change it all... But if the conditions might get changed or combined, then yeah.
Also if your condition is a function or some calculation, the switch avoids the need of a local variable to store the result before comparing it, which is practical.

IMHO

</offtopic>
Back to top
View users profile Send private message Add User to Ignore List
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Tue Jul 06, 2010 10:39 am    Post subject: Reply to topic Reply with quote

Samapico wrote:
Suggestion: Would be nice to be able to use printf style format with the ColorA, ColorP, etc. functions


it was on my to do list, but i hadnt added it yet because:
#1: its extra work
#2: you can use snprintf like samapico does before SendArenaMessage before PinkA
#3: idk
#4: its easy to do, and ill add it later sometime
#5: ???
#6: PROFIT


also, i use else if chains when i dont need fall-throughs or not-1-line code

edit:
keep in mind you can use %123 to add sounds to your messages...
its very infrequent that i actually use the SendSoundMessage stuff...

also, using
if(1) a++;
on one line is better than
if(1)
..........a++;
because its on one line instead of two, and is MORE readable.
only use two lines when one becomes less readable.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Tue Jul 06, 2010 12:59 pm    Post subject: Reply to topic Reply with quote

I personally find it less readable when the statement is on the same line as the conditon... you have to visually scroll to the end of the condition (i.e. the closing parenthesis) and then find the statement...

Anyway.... if you didn't notice, I did the printf format style functions, so you don't need to, in the post just after the one you quoted tongue.gif

Also, I know you can send the % sounds when you type a colored messages, but I'm mainly using the color module's interface from other modules and I doubt adding a %# in the message string would make a sound... the % thing is client-side.
Back to top
View users profile Send private message Add User to Ignore List
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Tue Jul 06, 2010 5:27 pm    Post subject: Reply to topic Reply with quote

when youre getting up to 10,000 lines of code, adding extra space for no reason makes you wait a really long time while scrolling to the part youre looking for.



yes, all sounds are client side, and yes, you did copy+paste from chat.c just like i will.

:)
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
L.C.
Server Help Squatter


Age:33
Gender:Gender:Male
Joined: Jan 03 2003
Posts: 574
Location: Missouri, US
Offline

PostPosted: Tue Jul 06, 2010 10:41 pm    Post subject: Reply to topic Reply with quote

Cheese wrote:
when youre getting up to 10,000 lines of code, adding extra space for no reason makes you wait a really long time while scrolling to the part youre looking for.
It makes sense to do it because it makes your code look cleaner, more accessible, easier to read, and easier to work with. I say this based off my XHTML/CSS experience. (Take a look at the source code for hlrse.net's webpage to see what I mean.)
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Wed Jul 07, 2010 8:19 am    Post subject: Reply to topic Reply with quote

i find them to be equally readable at best, but one is a waste of space
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Sun Jul 25, 2010 9:50 am    Post subject: Reply to topic Reply with quote

Samapico wrote:
Suggestion: Would be nice to be able to use printf style format with the ColorA, ColorP, etc. functions


I finally got around to doing this.
Enjoy.

files updated
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
BaK (mgb wont reset pw)
Guest


Offline

PostPosted: Sun Jul 25, 2010 8:01 pm    Post subject: Reply to topic Reply with quote

Dr Brain wrote:
if statements are more flexible, and therefore easier to expand in the future, and of course the basic form generates the same machine code.


don't case statements generate jump tables while if statements use a series of comparisons?
Back to top
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sun Jul 25, 2010 9:58 pm    Post subject: Reply to topic Reply with quote

How would you generate a jump table without comparisons, exactly? A fully populated table for ints would be 4GB (assuming the relative jump could be packed into 1 byte, of course). A sparse table would require comparisons and would start to look very much like that if-else tree.

Jump tables are great for strictly defined things like interrupt handling vectors, and custom code where you can write assembly to get the very last nanosecond out.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
BaK (mgb wont reset pw)
Guest


Offline

PostPosted: Mon Jul 26, 2010 7:57 am    Post subject: Reply to topic Reply with quote

if you're dense near 0, you check the maximum range once and then after that assume the index is in bounds.

I think the compiler did it when I was learning asm and it took me a minute to figure out what was going on.
Back to top
Guest



Offline

PostPosted: Mon Jul 26, 2010 7:59 am    Post subject: Reply to topic Reply with quote

Dr Brain wrote:
How would you generate a jump table without comparisons, exactly?


// done by compiler
table[0] = case0;
table[1] = case1;
table[2] = case2;
table[3] = case3;

// done at runtime
if (index > 3)
goto caseDefault;
else
goto table[index];
Back to top
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Mon Jul 26, 2010 10:05 am    Post subject: Reply to topic Reply with quote

You're right, you can do it with one comparison if you have fully dense cases. I've never seen it done, but again, I don't work with switch statements for the style reasons stated above.

I'd like to note that I don't think CPU branch predictors are well suited to that sort of jump table (relative jump with offset held in a register instead of an immediate). Branch predictors may have improved since I last studied them, but as I don't see how this kind of dependence could be resolved while still in the pipeline. So you'll get a pipeline flush every time you do the jump, which in deeply pipelined processors can hurt performance instead of helping it (modern x86_64 are deeply pipelined). The exact penalty depends on the probability distribution of the cases and the pipeline flush penalty, but except for truly massive switch statements or processors with shallow pipelines it won't reach break-even.

But, that said, any compiler smart enough to optimize a switch statement (if indeed there is an improvement from a jump table, which I tend to doubt) is probably smart enough to check if the if-else tree can follow the same optimization. It's a simple enough comparison of the AST to see if every branch of the if-else does an integer comparison against the same variable.

Perhaps the jump table is the -O0 behavior? That would make sense, since the argument could be made that it would more closely resemble the C code. Or perhaps it's -Os, if there's a code size savings (e.g. the relative offset could fit in a byte, but the branch opcodes are one word wide).

Most of the code I write isn't x86, so I may be unaware of new developments in the processor architecture. The last x86 I studied was the Pentium 4. Most of my code is C, written for the AVR and AVR32 architectures, compiled using gcc.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
BaK (mgb wont reset pw)
Guest


Offline

PostPosted: Thu Aug 12, 2010 12:11 pm    Post subject: Reply to topic Reply with quote

it doesn't need to be fully dense, as some gaps can be filled in with the same address (jump to the default handler, or after the switch statement).

Even in the case of a very sparse switch statement, it can be implemented using a binary search which will be faster than a sequential checking using if statements alone.
Back to top
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Thu Aug 12, 2010 12:39 pm    Post subject: Reply to topic Reply with quote

The pipeline flush from the jump table is still going to drive the performance cost on any x86 and x86_64.

And you don't think an optimizing compiler can rewrite them both into the same exact machine code? That was my original point: they'll generate the same exact binary. Therefore one should use whichever is easier to read, which for my money is the if else-if.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Thu Aug 12, 2010 4:26 pm    Post subject: Reply to topic Reply with quote

ive always wanted an elseif switch

Code: Show/Hide

elseifswitch(num)
{
case > 3: break;
case > 2: break;
case > 1: break;
}
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Custom Projects All times are GMT - 5 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 276 page(s) served in previous 5 minutes.

phpBB Created this page in 0.567947 seconds : 52 queries executed (90.2%): GZIP compression disabled