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
Terminating a Loop
Goto page Previous  1, 2
 
Post new topic   Reply to topic Printable version
 View previous topic  MervBot problem... Post :: Post Continuing (MERVBot CTF plugin)  View next topic  
Author Message
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Mon Sep 06, 2004 7:06 pm    Post subject: Reply to topic Reply with quote

If your debugger can't step into any line of source code, then it's not a real debugger. And if you can't handle stepping into an extra level of function calls in ASM, then don't program. icon_smile.gif
_________________
4,691 irradiated haggis!
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Mon Sep 06, 2004 9:47 pm    Post subject: Reply to topic Reply with quote

So what do you recommend here?
Code: Show/Hide
case WM_INITDIALOG:
   for (i = 0; i < NUM_MSGS; i++)
      SendDlgItemMessage(page, IDC_M_SEL, CB_ADDSTRING, 0, (LPARAM)message_names[i]);
   for (i = 0; i < NUM_CINEM; i++)
      SendDlgItemMessage(page, IDC_M_SELC, CB_ADDSTRING, 0, (LPARAM)cinem_names[i]);
   return TRUE;

_________________
This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
50% Packetloss
Server Help Squatter


Age:40
Gender:Gender:Male
Joined: Sep 09 2003
Posts: 561
Location: Santa Clarita, California
Offline

PostPosted: Mon Sep 06, 2004 10:42 pm    Post subject: Reply to topic Reply with quote

You break; out of the switch. Never have a return except at the end of the function.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Tue Sep 07, 2004 12:24 am    Post subject: Reply to topic Reply with quote

Code: Show/Hide
BOOL DialogProc (...)
{
BOOL ret = FALSE;

...

switch (msg)
   {
   ...

   case WM_INITDIALOG:

      for (i = 0; i < NUM_MSGS; i++)
         SendDlgItemMessage(page, IDC_M_SEL, CB_ADDSTRING, 0, (LPARAM)message_names[i]);

      for (i = 0; i < NUM_CINEM; i++)
         SendDlgItemMessage(page, IDC_M_SELC, CB_ADDSTRING, 0, (LPARAM)cinem_names[i]);
     
      ret = TRUE;
      break;

   ...
   }

return (ret);
}


Glad to see you are using raw Win32. icon_smile.gif

Almost all messages you return FALSE if you handle them, so set return once at top, and only change in special cases.
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Tue Sep 07, 2004 12:56 am    Post subject: Reply to topic Reply with quote

It's still ugly though... and it's not like having a return there is a safety hazard in any way. I just don't think we all should be so strict about it.

On a side note, I #included the old iostream headers today in Dev-C++ and it complained at me for not using those darned template classes. Like I really need all that code bloating the size of my executable? Basically, I say all us likers of clean code (even if we do disagree on returns) should stage a coup d'etat against ANSI, MS, and Mr. Plauger and rule the world in its place. Or maybe I'm just really too tired to be talking.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:41
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3615
Location: Las Vegas
Offline

PostPosted: Tue Sep 07, 2004 1:03 am    Post subject: Reply to topic Reply with quote

Cyan~Fire wrote:
Like I really need all that code bloating the size of my executable?

I'm sure nothing you are making right now even comes close to the efficiency of making a program that will need real-time speed. And the size of the executable is negligable for what you are working with.

Cleanliness isn't always the best. Whats important, is that someone else ten years from now is able to look over your source code, understand most of what is there without reading any outside information (ie: no manual, only source comments), and be able to modify it or convert it to what he needs. If that means making your source a bit ugly at a glance, so that someone can determine what you are doing, thats a good trade off.
Back to top
View users profile Send private message Add User to Ignore List Send email
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Tue Sep 07, 2004 4:39 am    Post subject: Reply to topic Reply with quote

Cyan~Fire wrote:
It's still ugly though... and it's not like having a return there is a safety hazard in any way. I just don't think we all should be so strict about it.

On a side note, I #included the old iostream headers today in Dev-C++ and it complained at me for not using those darned template classes. Like I really need all that code bloating the size of my executable? Basically, I say all us likers of clean code (even if we do disagree on returns) should stage a coup d'etat against ANSI, MS, and Mr. Plauger and rule the world in its place. Or maybe I'm just really too tired to be talking.


If you look at each function and decide "this one doesn't need to be so strict" and "this one does", then you fall into the trap of making a mess as you edit, design, maintain, and evolve. You will often find that a simple function where you didn't care suddenly got more complex. But you don't have the time right now to fix it, so it gets big and buggy. What would have taken 5 seconds to do right the first time now takes you a week to debug. I've seen it over and over: malloc/free, open/close, create/destroy, new/delete, uninitialized variables, things that make your app a system hog but not crash, etc.

I don't know your experience level, your career, or how old you are, but I think you will find yourself becoming more strict as you go after betting burned or watching it happen in other people's code in the same project you are one (when you have to work all weekend to find the function they didn't care to design right).
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Tue Sep 07, 2004 10:34 am    Post subject: Reply to topic Reply with quote

MGB wrote:
I'm sure nothing you are making right now even comes close to the efficiency of making a program that will need real-time speed. And the size of the executable is negligable for what you are working with.

I like to keep my executables small. There is also a C runtime library I use to do so. If it's going to get mad at me about using that CRT, I'm going to get mad at it. The whole effeciency/size thing is not that I think it will make a difference in the program, it's just that it could always be better so I will always be trying to make it better.

Ekted wrote:
If you look at each function and decide "this one doesn't need to be so strict" and "this one does", then you fall into the trap of making a mess as you edit, design, maintain, and evolve.

Except that I never use mid-function returns unless it's a function that's never going to do anything that requires cleanup. And in my WindowProcs, I just use break if it's going to return 0 and return something else if necessary. If the 'something else' ends up complex enough to need cleanup, I stick it in a handler anyway.

Ekted wrote:
I don't know your experience level, your career, or how old you are, but I think you will find yourself becoming more strict as you go after betting burned or watching it happen in other people's code in the same project you are one (when you have to work all weekend to find the function they didn't care to design right).

My programming is purely hobbyist right now, but AFAIK I'll end up in a corporate environment. If I have to deal with others' messy code, I'm going to have to worry about a heck of a lot more than returns, I believe. However, if my current plan of things works out, I'm going to be co-founding a video game company... but that's probably just pretentions.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Tue Sep 07, 2004 2:02 pm    Post subject: Reply to topic Reply with quote

Quote:
However, if my current plan of things works out, I'm going to be co-founding a video game company... but that's probably just pretentions.


I'll work for you. icon_smile.gif
Back to top
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Tue Sep 07, 2004 3:39 pm    Post subject: Reply to topic Reply with quote

rotfl...
_________________
Performance is often the art of cheating carefully. - James Gosling
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Tue Sep 07, 2004 7:50 pm    Post subject: Reply to topic Reply with quote

More like I'll work for you, since I'm sure you wouldn't ever want me controlling what you code icon_razz.gif
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Tue Sep 07, 2004 9:33 pm    Post subject: Reply to topic Reply with quote

Cyan~Fire wrote:
More like I'll work for you, since I'm sure you wouldn't ever want me controlling what you code icon_razz.gif


No one I've ever worked for controlled my code. You hire really good people, pay them whatever they want, and let them do whatever they want. That's how you get results. Hiring people that will work for 50K, putting them in rows of cubicles, managing them with unqualified people (ie non-techies), making them work 9-5, go to meetings, fill out time sheets, dress codes, or expecting everyone to conform to some arbitrary system is a sure-fire way to make sure that progress and morale are crap.

3 people in the first situation can out-perform 30 in the second.
Back to top
View users profile Send private message Add User to Ignore List
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Thu Sep 09, 2004 4:35 pm    Post subject: Reply to topic Reply with quote

And if Ek works for Cyan he will never be out of a job constantly cleaning up his code.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Thu Sep 09, 2004 4:44 pm    Post subject: Reply to topic Reply with quote

Fixing my returns... hahaha.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Bot Questions All times are GMT - 5 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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: 40 page(s) served in previous 5 minutes.

phpBB Created this page in 0.487818 seconds : 38 queries executed (87.0%): GZIP compression disabled