Raised This Month: $51 Target: $400
 12% 

Coding Suggestion/Feedback about your style


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mitchell
~lick~
Join Date: Mar 2010
Old 05-22-2014 , 09:50   Coding Suggestion/Feedback about your style
Reply With Quote #1

This is a thread mainly to learn about other's coding style for their respective game they code for.
If there is already a thread like this, possibly point it out to me?

Anyways i'll start it off, I like to see how far I can code a plugin without actually having to compile it. This mainly includes comments (comments are good! allows people to read my code and know what i'm accomplishing!), and me planning out what each function should do before hand. Then i write up some mock up code in each function, just to start off with a base. Depending on the plugin, if it is a small plugin, then i usually get around 75% of it done. Once i get that far I try and compile it. Of course there will be errors, mainly errors of me not defining variables that I use. I sometimes misspell a variable here and there. When I work on a bigger plugin, I usually break it down to pieces, getting the base code done first, and then adding in all the cool stuff later. Then I test it out on the server to make sure it works the way i want it to.
I find my method works for me because I go at least 4 days without being a PC that can handle any Source game (hardly even minecraft). I usually finish up a lot of the code while im on my laptop (at work) then spend a day debugging it at the end of the week.

TL;DR:
  1. Code 75%
  2. Compile for Errors
  3. Test on server
  4. Finish coding/Changes
  5. Compile/Test on server
  6. done.

I would like to hear about other's methods, since it's always nice to hear something new to try out. Also it might help some of the new people.

Last edited by Mitchell; 05-22-2014 at 09:52.
Mitchell is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 05-22-2014 , 13:23   Re: Coding Suggestion/Feedback about your style
Reply With Quote #2

How I usually work
  1. Defining main features of Plugin.
  2. Code until I think they are done.
  3. Test on Server.
  4. (Optional) Fix Bugs.
  5. Add Optional Features (Models, Sounds etc.)
  6. Eat Cake.
  7. Done.
__________________
Kia is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 05-22-2014 , 13:50   Re: Coding Suggestion/Feedback about your style
Reply With Quote #3

My things:
1. Planning what im going to do and how im going to do it.
2. creating all the stock and functions what needed
3. if plugin/program size is 20-40kb then code everything whats on my mind
4. Fixing compile errors if needed.
5. testing them on my computer ( not using any server or something like that )
6. Fixing bugs if needed
7. Always, adding some more stuff what i didnt plan for in the beggining
8. placing cake on kia's table
9. Program&plugin done.
.Dare Devil. is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-22-2014 , 14:27   Re: Coding Suggestion/Feedback about your style
Reply With Quote #4

If you really want a list of things...
  1. Figure out if a plugin is feasible to do or not.
  2. If this requires any sort of gamedata, figure out what the Linux gamedata is.
    1. If this is for Source games, such as TF2, cheat by looking for relevant code in the Source SDK 2013 because Valve forgot to remove the #ifdef TF and #ifdef TF_CLIENT parts, so you can see what the server is actually doing. This also helped me figure out what the TextMsg UserMessage actually does (print Valve-translations to clients).
  3. If this is intended to be a permanent project, create a new source-code repo for it.
  4. Copy my plugin template / plugin .inc template (if plugin will have natives) to said repo or make a copy in my snippets repo, then update it for the current project.
  5. Sort out any required dependencies and make sure they're loaded.
  6. Create any translation files that might be necessary. That way I can't forget to do it later.
  7. Add the code to register any commands or events. That way, they error out if I forget to write them before coding them.
  8. Write the actual code.
  9. If the plugin is large enough, split it into multiple files along natural encapsulation boundaries (See: SourceMod's NativeVotes* plugin, which splits native handling, data handling, and game-specific code (which themselves are the wrappers and actual game-specific logic)).
    1. Make sure includes are all in the proper order.
  10. Compile the code.
  11. If the code doesn't compile, go fix bugs.
  12. If the code does compile and my test server is empty, lock it and put the plugin up there for testing.
  13. Add bots for testing if appropriate.
  14. If it requires gamedata signatures, ask someone what the Windows signature is since I'm still not sure how to do Windows sigscanning.

*NativeVotes may be a bad example as it originally started out as C++ code with separate classes for L4D, L4D2, and TF2... with a shared base for L4D and L4D2.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-22-2014 at 14:28.
Powerlord is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 05-22-2014 , 20:49   Re: Coding Suggestion/Feedback about your style
Reply With Quote #5

Quote:
Originally Posted by Powerlord View Post
If you really want a list of things...
  1. Figure out if a plugin is feasible to do or not.
  2. If this requires any sort of gamedata, figure out what the Linux gamedata is.
    1. If this is for Source games, such as TF2, cheat by looking for relevant code in the Source SDK 2013 because Valve forgot to remove the #ifdef TF and #ifdef TF_CLIENT parts, so you can see what the server is actually doing. This also helped me figure out what the TextMsg UserMessage actually does (print Valve-translations to clients).
  3. If this is intended to be a permanent project, create a new source-code repo for it.
  4. Copy my plugin template / plugin .inc template (if plugin will have natives) to said repo or make a copy in my snippets repo, then update it for the current project.
  5. Sort out any required dependencies and make sure they're loaded.
  6. Create any translation files that might be necessary. That way I can't forget to do it later.
  7. Add the code to register any commands or events. That way, they error out if I forget to write them before coding them.
  8. Write the actual code.
  9. If the plugin is large enough, split it into multiple files along natural encapsulation boundaries (See: SourceMod's NativeVotes* plugin, which splits native handling, data handling, and game-specific code (which themselves are the wrappers and actual game-specific logic)).
    1. Make sure includes are all in the proper order.
  10. Compile the code.
  11. If the code doesn't compile, go fix bugs.
  12. If the code does compile and my test server is empty, lock it and put the plugin up there for testing.
  13. Add bots for testing if appropriate.
  14. If it requires gamedata signatures, ask someone what the Windows signature is since I'm still not sure how to do Windows sigscanning.

*NativeVotes may be a bad example as it originally started out as C++ code with separate classes for L4D, L4D2, and TF2... with a shared base for L4D and L4D2.
And not giving cake to give it to @Kie...
Alright then ...
.Dare Devil. is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-22-2014 , 23:16   Re: Coding Suggestion/Feedback about your style
Reply With Quote #6

Quote:
Originally Posted by .Dare Devil. View Post
And not giving cake to give it to @Kie...
Alright then ...
I'm supposed to watch my sugar, so... cake limit!
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 05-23-2014 , 02:55   Re: Coding Suggestion/Feedback about your style
Reply With Quote #7

Some of you don't seem to use a local server to test, why not?
__________________

Last edited by Impact123; 05-23-2014 at 03:02.
Impact123 is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 05-23-2014 , 04:50   Re: Coding Suggestion/Feedback about your style
Reply With Quote #8

Quote:
Originally Posted by Impact123 View Post
Some of you don't seem to use a local server to test, why not?
Because we / I have a VPS / rented Gameserver to test there?
Most often I test with other players, and my own connection is not good.
__________________
Kia is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-23-2014 , 09:11   Re: Coding Suggestion/Feedback about your style
Reply With Quote #9

Quote:
Originally Posted by Impact123 View Post
Some of you don't seem to use a local server to test, why not?
Because I lease my own game server. You can see it in my signature.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 05-23-2014 , 10:33   Re: Coding Suggestion/Feedback about your style
Reply With Quote #10

Quote:
Originally Posted by Impact123 View Post
Some of you don't seem to use a local server to test, why not?
I do, cause i'm poor. not really. But when i want to test experimental features i most of the time do it on a srcds. Or if my test server a friend lends me then i just do it there. Mainly use a local server if its something i don't need another human to help me test.
Mitchell is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode