Author Topic: ServerCFG Generator 1.0 | The {NaNo} Development team  (Read 5359 times)

kill3r

  • Posts: 40
  • Turrets: +4/-4
ServerCFG Generator 1.0 | The {NaNo} Development team
« on: August 31, 2009, 05:00:40 am »
Hello,
I made a program that can assist begginers in making a server.cfg. It is around 350+ lines of code, and 1.5MB in size uncompressed. Please reply with your feedback. This is the work from the {NaNo} Development team.
~~~~
Install
Simply place the ServerCFG.exe in the folder where you want the server.cfg to appear (default: C:\Program Files\Tremulous\base\).
~~~~
ServerCFG 1.0 Guide
~~~~
Setup:
Before you 'run' this program, it is highly reccomended that you place the executable (ServerCFG.exe) in your tremulous base folder. When the executable is in the desired location, execute it as a normal user (if on Windows XP). Make sure that you have permissions from the administrator before using this program.
Using the program
When you execute this program, you will see a console window; Simply press 'enter' to get past the credits. Now, it is reccomended that you choose 'Edit Cvar's' before you Create the server.cfg. Without editing the Cvar's, all the values in server.cfg will be set to default. If at any time you wish to delete the server.cfg, choose 'Remove server.cfg' From the menu. If you made a mistake while editing the Cvar's, goto the main menu, and choose 'Reset Cvar's'.
Download link:http://www.mediafire.com/download.php?zzd2yzzomhn

Archangel

  • Guest
Re: ServerCFG Generator 1.0 | The {NaNo} Development team
« Reply #1 on: August 31, 2009, 05:02:28 am »
350 lines of code shouldn't == 1.5mb..

and especially a CLI app.

it also breaks if you enter a text value in a numeric input and starts to spam your terminal.

there's also a lot of typos.

OVERALL: a very unimpressive application
« Last Edit: August 31, 2009, 05:08:38 am by Archangel »

kill3r

  • Posts: 40
  • Turrets: +4/-4
Re: ServerCFG Generator 1.0 | The {NaNo} Development team
« Reply #2 on: August 31, 2009, 05:22:58 am »
Hey it's a start for a little 12 year old like me :P
Also archangel- The only way i see it entering a infinite loop is by entering a character when it expects a integer. Where did you see this happen?
Thanks for your reply Archangel, I know my first program wont be perfect :p, As i can only build on criticism
« Last Edit: August 31, 2009, 05:26:36 am by kill3r »

Colynn'

  • Posts: 308
  • Turrets: +28/-35
Re: ServerCFG Generator 1.0 | The {NaNo} Development team
« Reply #3 on: August 31, 2009, 12:04:46 pm »
Keep working!
Currently working on: REAL LIFE STUDIES BULLSHIT

Ellohir

  • Posts: 192
  • Turrets: +14/-13
    • El balrog con alas
Re: ServerCFG Generator 1.0 | The {NaNo} Development team
« Reply #4 on: August 31, 2009, 12:59:11 pm »
There's no linux version? Or at least the source to port it? :/

kill3r

  • Posts: 40
  • Turrets: +4/-4
Re: ServerCFG Generator 1.0 | The {NaNo} Development team
« Reply #5 on: August 31, 2009, 02:43:25 pm »
Code: [Select]
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <direct.h>
#include <windows.h>
#include <string>
//Default values if user does not specify the variable
#define G_UNLAGGED 1
#define G_GRAVITY 800
#define TIMELIMIT 60
#define G_KNOCKBACK 1000
#define G_HUMANBUILDPOINTS 200
#define G_ALIENBUILDPOINTS 200
#define G_FRIENDLYFIRE 1
#define SV_MAXPING 500
#define SV_MINPING 0
#define G_MOTD "Welcome to the server...Have fun!"
#define SV_HOSTNAME "My Server"
#define G_FRIENDLYBUILDABLEFIRE 1
#define G_ALIENMAXSTAGE 2
#define G_HUMANMAXSTAGE 2
#define RCONPASSWORD "password"
#define SV_PURE 1
#define G_ALLOWVOTE 1
#define G_INITIALMAPROTATION "rotation1"
#define G_ADMINNAMEPROTECT 1
#define G_PRIVATEMESSAGES 1
#define FIRSTMAP "atcs"
//End of default values
using namespace std;

int main()
{
    verystart:
    //Making the file properties
    ofstream cfg;
    //end of making the file properties
    //Define our variables
    int g_unlagged = G_UNLAGGED;
    int g_gravity = G_GRAVITY;
    int timelimit = TIMELIMIT;
    int g_knockback = G_KNOCKBACK;
    int g_humanbuildpoints = G_HUMANBUILDPOINTS;
    int g_alienbuildpoints = G_ALIENBUILDPOINTS;
    int g_friendlyfire = G_FRIENDLYFIRE;
    int sv_maxping = SV_MAXPING;
    int sv_minping = SV_MINPING;
    string g_motd = G_MOTD;
    string sv_hostname = SV_HOSTNAME;
    int g_friendlybuildablefire = G_FRIENDLYBUILDABLEFIRE;
    int g_alienmaxstage = G_ALIENMAXSTAGE;
    int g_humanmaxstage = G_HUMANMAXSTAGE;
    string rconpassword = RCONPASSWORD;
    int sv_pure = SV_PURE;
    int g_allowvote = G_ALLOWVOTE;
    string g_initialmaprotation = G_INITIALMAPROTATION;
    int g_adminnameprotect = G_ADMINNAMEPROTECT;
    int g_privatemessages = G_PRIVATEMESSAGES;
    string firstmap = FIRSTMAP;
    //End of our variables
    //Additional in-program variables
    int selection;
    int intselect;
    string stringselect;
    //end of additional in-program variables
    system("color fc");
    //start
    start:
    //start
    cout <<"Server Config generator 1.0. Copyright The {NaNo} Development Team\n";
    cout <<"Press enter to continue...\n";
    cin.get();
    menu:
    system("cls");
    //menu

    //menu
    //This is the main menu
    cout <<"ServerCFG->Menu\n\n";
    cout <<"1: Create server.cfg\n";
    cout <<"2: Edit Cvar's\n";
    cout <<"3: Remove server.cfg\n";
    cout <<"4: Reset all cvar's to default\n";
    cout <<"5: Exit\n";
    cin >> selection;
    //start of the 'big' loop
    if (selection == 1) {
        cout <<"Creating server.cfg in current directory... Please wait\n";

        cfg.open("server.cfg", ios::trunc);
        cfg << "//Generated server.cfg. Copyright The {NaNo}Development Team\n";
        cfg << "set g_gravity " << g_gravity << "\n";
        cfg << "set g_knockback " << g_knockback << "\n";
        cfg << "set timelimit " << timelimit << "\n";
        cfg << "set g_unlagged " << g_unlagged << "\n";
        cfg << "set g_humanbuildpoints " << g_humanbuildpoints << "\n";
        cfg << "set g_alienbuildpoints " << g_alienbuildpoints << "\n";
        cfg << "set g_friendlyfire " << g_friendlyfire << "\n";
        cfg << "set sv_maxping " << sv_maxping << "\n";
        cfg << "set sv_minping " << sv_minping << "\n";
        cfg << "set g_motd '" << g_motd <<"'\n";
        cfg << "set sv_hostname '" << sv_hostname <<"'\n";
        cfg << "set g_friendlybuildablefire " << g_friendlybuildablefire <<"\n";
        cfg << "set g_alienmaxstage " << g_alienmaxstage << "\n";
        cfg << "set g_humanmaxstage " << g_humanmaxstage << "\n";
        cfg << "set rconpassword '" << rconpassword << "'\n";
        cfg << "set sv_pure " << sv_pure << "'\n";
        cfg << "set g_allowvote " << g_allowvote << "\n";
        cfg << "set g_initialmaprotation '" << g_initialmaprotation <<"'\n";
        cfg << "set g_adminnameprotect " << g_adminnameprotect <<"\n";
        cfg << "set g_privatemessages " << g_privatemessages << "\n";
        cfg << "map " << firstmap <<"\n";
        cfg.close();
        MessageBox(NULL,"Added server.cfg to the current directory","ServerCFG",MB_OK | MB_ICONINFORMATION);
        cout <<"\nComplete\n";
        cin.get();
        goto menu;
    }
    //End of writing file
    //start of a lot of rotations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    if (selection == 2) {
        editmenu:
        system("cls");
        cout << "ServerCFG->Menu->Edit\n";
        cout << "WARNING: ONLY EDIT THE VALUES THAT YOU WANT TO CHANGE. UNCHANGED VALUES WILL BE SET TO DEFAULT\n";

        cout << " 1: Change Server name\n";
        cout << " 2: Change wether or not there should be a 'lag' filter\n";
        cout << " 3: Change the gravity level\n";
        cout << " 4: Change timelimit\n";
        cout << " 5: Change knockback\n";
        cout << " 6: Change How many build points humans have\n";
        cout << " 7: Change how many build points aliens have\n";
        cout << " 8: Change wether or not team-mates are effected by them attacking each-other\n";
        cout << " 9: Change the maximum latency (ping) between the client and the server\n";
        cout << "10: Change the minimum latency (ping) between the client and the server\n";
        cout << "11: Change the screen with text when a client is entering the server\n";
        cout << "12: Change wether or not building are effected by the same team when shot\n";
        cout << "13: Change The maximum stage that Aliens can achieve\n";
        cout << "14: Change the maximum stage that Huamns can achieve\n";
        cout << "15: Change the remote control (rcon) password\n";
        cout << "16: Change wether or not client's can connect with a modified executable\n";
        cout << "17: Change wether or not connected clients can call votes\n";
        cout << "18: Change the name of the map rotation\n";
        cout << "19: Change wether or not Administrator's names are protected\n";
        cout << "20: Change wether or not connected client's can send private messages\n";
        cout << "21: Change the first map when the server start's\n";
        cout << "22: Exit to Main menu\n";
        cin >> selection;
        //inner selection
        if (selection == 1) {
            cout <<"Please enter the new server name (without quotations): ";
            cin.get();
            getline(cin,stringselect);
            sv_hostname = stringselect;
            goto editmenu;
        }
        if (selection == 2) {
            cout << "Should we apply a 'lag' filter? (1 = Yes, 0 = No): ";
            cin >> intselect;
            g_unlagged = intselect;
            goto editmenu;
        }

         if (selection == 3) {
             cout << "What should be the gravity number?: ";
             cin >> intselect;
             g_gravity = intselect;
             goto editmenu;
         }
         if (selection == 4) {
             cout << "What should be the timelimit?: ";
             cin >> intselect;
             timelimit = intselect;
             goto editmenu;
         }
         if (selection == 5) {
             cout << "What should be the knockback?: ";
             cin >> intselect;
             g_knockback = intselect;
             goto editmenu;
         }
         if (selection == 6) {
             cout << "How many build points should Humans have?: ";
             cin >> intselect;
             g_humanbuildpoints = intselect;
             goto editmenu;
         }
         if (selection == 7) {
             cout << "How many build points should Aliens have?: ";
             cin >> intselect;
             g_alienbuildpoints = intselect;
             goto editmenu;
         }
         if (selection == 8) {
             cout << "Should friendly fire be on or of? (1 = On, 0 = Off): ";
             cin >> intselect;
             g_friendlyfire = intselect;
             goto editmenu;
         }
         if (selection == 9) {
             cout << "What should be the maximum ping from the client?: ";
             cin >> intselect;
             sv_maxping = intselect;
             goto editmenu;
         }
         if (selection == 10) {
             cout << "What should be the minimum ping from the client?: ";
             cin >> intselect;
             sv_minping = intselect;
         }
         //FIXED

         if (selection == 11) {
            cout << "What should be the text when a client enter's a server?: ";
            cin.get();
            std::getline (std::cin,stringselect);
            g_motd = stringselect;
            goto editmenu;
        }
        //End of 'To fix'
        if (selection == 12) {
            cout << "Will whooting at your own building effect them? (1 = Yes, 0 = No): ";
            cin >> intselect;
            g_friendlybuildablefire = intselect;
            goto editmenu;
         }
         if (selection == 13) {
             cout << "What should be the Human's maximum stage?: ";
             cin >> intselect;
             g_humanmaxstage = intselect;
             goto editmenu;
         }
         if (selection == 14) {
             cout << "What should be the Alien's maximum stage?: ";
             cin >> intselect;
             g_alienmaxstage = intselect;
             goto editmenu;
         }
         if (selection == 15) {
             cout << "What should be the new remote control (rcon) password?: ";
             cin.get();
             getline(cin,stringselect);
             rconpassword = stringselect;
             goto editmenu;
         }
         if (selection == 16) {
             cout << "Should clients be able to connect with a modified executable? (1 = Yes, 0 = No): ";
             cin >> intselect;
             sv_pure = intselect;
             goto editmenu;
         }
         if (selection == 17) {
             cout << "Should connected client's be able to call a vote? (1 = Yes, 0 = No): ";
             cin >> intselect;
             g_allowvote = intselect;
             goto editmenu;
         }
         if (selection == 18) {
             cout << "What should be the new name of the map rotation?: ";
             cin.get();
             getline (cin,stringselect);
             g_initialmaprotation = stringselect;
             goto editmenu;
         }
         if (selection == 19) {
             cout << "Should administrator's names be protected from other's using them? (1 = Yes, 0 = No): ";
             cin >> intselect;
             g_adminnameprotect = intselect;
             goto editmenu;
         }
         if (selection == 20) {
             cout << "Should connected client's send private messages? (1 = Yes, 0 = No): ";
             cin >> intselect;
             g_privatemessages = intselect;
             goto editmenu;
         }
         if (selection == 21) {
             cout << "What should be the first map when the server starts?: ";
             cin.get();
             getline (cin,stringselect);
             firstmap = stringselect;
         }
        if (selection == 22) {
            goto menu;
        }
        //if they dont enter anything....
        else {
            goto editmenu;
        }

    }
    //Done of a lot of rotation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    if (selection == 3) {
        int result = (MessageBox(NULL,"Are you sure?","ServerCFG",MB_YESNO | MB_ICONWARNING));
        if (result == IDYES) {
        remove("server.cfg");
        MessageBox(NULL,"Removed server.cfg","ServerCFG",MB_OK | MB_ICONINFORMATION);
        goto menu;
        }
        if (result == IDNO) {
            MessageBox(NULL,"Aborted","ServerCFG", MB_ICONSTOP | MB_OK);
        goto menu;
        }
    }
    //End of selection2 and editing cvar's
    //the else statment
    if (selection == 4) {
        int answer = MessageBox(NULL,"Are you sure?","ServerCFG",MB_YESNO | MB_ICONWARNING);
        if (answer == IDYES) {
            goto verystart;
        }
        else {
            goto start;
        }
    }
    if (selection == 5) {
        goto end;
    }

    else {
        cout <<"Invalid selection\n";
        cin.get();
        goto menu;
    }
    //end of the 'big' loop
    end:;
    MessageBox(NULL,"Thanks for using ServerCFG\n Visit us at:\n xnano.freeforums.org","ServerCFG",MB_OK | MB_ICONINFORMATION);
}
There is the source if anyone needs it. However i am working on a linux version at the moment.

Archangel

  • Guest
Re: ServerCFG Generator 1.0 | The {NaNo} Development team
« Reply #6 on: August 31, 2009, 08:06:08 pm »
AHHHHH GOTO LOOPS MY FACE HURTS SO BAD

Ellohir

  • Posts: 192
  • Turrets: +14/-13
    • El balrog con alas
Re: ServerCFG Generator 1.0 | The {NaNo} Development team
« Reply #7 on: August 31, 2009, 08:28:30 pm »
I <3 ANSI C

A Spork

  • Spam Killer
  • *
  • Posts: 1010
  • Turrets: +37/-230
    • Spork - Unvanquished.net
Re: ServerCFG Generator 1.0 | The {NaNo} Development team
« Reply #8 on: August 31, 2009, 10:14:27 pm »
oh my thats some code that needs fixing.
Don't shoot friend :basilisk:! Friend :basilisk: only wants to give you hugz and to be your hat

Proud Member of the S.O.B.F.O.B.S.A.D: The Society Of Basilisks For Other Basilisks Safety and Dominance
:basilisk:    :basilisk:    :basilisk:

SlackerLinux

  • Spam Killer
  • *
  • Posts: 555
  • Turrets: +41/-62
Re: ServerCFG Generator 1.0 | The {NaNo} Development team
« Reply #9 on: August 31, 2009, 11:53:10 pm »
oh my thats some code that needs fixing.

true.

but he said hes 12 so its prob an ok try. id move most of the code out into separate functions at least also don't use goto statements they are messy.
do you really need msg boxes removing those and windows.h may make it work on linux and windows(itll get you closer atleast). that should help you improve on it a little.
Slackware64 13.1
SlackersQVM/

MitSugna

  • Guest
Re: ServerCFG Generator 1.0 | The {NaNo} Development team
« Reply #10 on: September 01, 2009, 12:01:49 am »
It has nothing to do with age. Ameanieou is just 11 years old( he claims to be older though ) and he did tremfusion.
I don't want to discourage old programmers. :P

Baconizer

  • Posts: 221
  • Turrets: +80/-52
    • Barking Frogs
Re: ServerCFG Generator 1.0 | The {NaNo} Development team
« Reply #11 on: September 01, 2009, 12:16:53 am »
I was under the impression that kill3r "developes programs written in C,Pascal,C++,Java and fortran." He also "uses two OS's:OpenSolaris and windows XP Pro"

I would have thought that would mean he had a bit of experience.

Also, please don't paste the entire source code of an application (unless it's very, very small) in a forum post. Ever.
Why will you folk not ban me? :'(

Bissig

  • Posts: 1309
  • Turrets: +103/-131
Re: ServerCFG Generator 1.0 | The {NaNo} Development team
« Reply #12 on: September 01, 2009, 12:18:35 am »
It has nothing to do with age. Ameanieou is just 11 years old( he claims to be older though ) and he did tremfusion.
I don't want to discourage old programmers. :P

11? He is at least 16 according to his own homepage.

@others

I love goto loops! Atari Basic FOREVER!

David

  • Spam Killer
  • *
  • Posts: 3543
  • Turrets: +249/-273
Re: ServerCFG Generator 1.0 | The {NaNo} Development team
« Reply #13 on: September 01, 2009, 12:35:07 am »
Also, please don't paste the entire source code of an application (unless it's very, very small) in a forum post. Ever.

Looks very small to me, and it's in code tags, so what's the problem?
Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.

Archangel

  • Guest
Re: ServerCFG Generator 1.0 | The {NaNo} Development team
« Reply #14 on: September 01, 2009, 02:00:29 am »
alaskan bandwidth caps
Quote
| date[Mon Aug 31] tty[9] host[serendipity]
 \ pwd[~] user[solar]%  g++ nano.cc -o nano
| date[Mon Aug 31] tty[9] host[serendipity]
 \ pwd[~] user[solar]%  ./nano
Server Config generator 1.0. Copyright The {NaNo} Development Team
Press enter to continue...

ServerCFG->Menu

just remove the message boxes plz.also, inspires me to write a better version, which i shall do soon.
« Last Edit: September 01, 2009, 02:04:24 am by Archangel »