/*************************************************************************** * Copyright (C) 2008 by mj * * hanfman_cool@web.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ //steamserverutil is a program to manage the steam game servers from hldsupdatetool.bin //v0.23, last changes: 23.07.08 13:53 //#ifdef HAVE_CONFIG_H //#include //#endif //#include #include #include #include #include using namespace std; //global variables char param[500]; //here are the params from function choice_params() saved //to test if server is currently installed bool server_css, server_dods, server_garrysmod, server_hl2mp, server_tf, server_cs, server_czero, server_dmc, server_dod, server_gearbox, server_ricochet, server_tfc, server_darkmessiah; //functions void not_installed() {cout << "\n\nServer not installed!";} void never_happen() {cout << "\n\nThis should never happen!! Please report a bug to hanfman_cool@web.de";} //tests which server are installed void is_installed() { cout << "\n\nServers available: \n\n"; //testing if games are installed ifstream test_reg; test_reg.open("server_css/InstallRecord.blob"); if(test_reg.is_open()) { cout << "1. Counter Strike Source\n"; server_css = true; } test_reg.close(); test_reg.open("server_dods/InstallRecord.blob"); if(test_reg.is_open()) { cout << "2. Day of Defeat Source\n"; server_dods=true; } test_reg.close(); test_reg.open("server_garrysmod/InstallRecord.blob"); if(test_reg.is_open()) { cout << "4. Garrys Mod\n"; server_garrysmod = true; } test_reg.close(); test_reg.open("server_hl2mp/InstallRecord.blob"); if(test_reg.is_open()) { cout << "5. Half Life 2 Deathmatch\n"; server_hl2mp=true; } test_reg.close(); test_reg.open("server_tf/InstallRecord.blob"); if(test_reg.is_open()) { cout << "6. Team Fortress\n"; server_tf = true; } test_reg.close(); test_reg.open("server_cs/InstallRecord.blob"); if(test_reg.is_open()) { cout << "7. Counter Strike\n"; server_cs=true; } test_reg.close(); test_reg.open("server_czero/InstallRecord.blob"); if(test_reg.is_open()) { cout << "8. Counter Strike Condition Zero\n"; server_czero = true; } test_reg.close(); test_reg.open("server_dmc/InstallRecord.blob"); if(test_reg.is_open()) { cout << "9. Deathmatch Classic\n"; server_dmc=true; } test_reg.close(); test_reg.open("server_dod/InstallRecord.blob"); if(test_reg.is_open()) { cout << "10. Day of Defeat\n"; server_dod = true; } test_reg.close(); test_reg.open("server_gearbox/InstallRecord.blob"); if(test_reg.is_open()) { cout << "11. Opposing Force\n"; server_gearbox=true; } test_reg.close(); test_reg.open("server_ricochet/InstallRecord.blob"); if(test_reg.is_open()) { cout << "12. Ricochet\n"; server_ricochet = true; } test_reg.close(); test_reg.open("server_tfc/InstallRecord.blob"); if(test_reg.is_open()) { cout << "13. Team Fortress Classic\n"; server_tfc=true; } test_reg.close(); test_reg.open("server_darkmessiah/InstallRecord.blob"); if(test_reg.is_open()) { cout << "15. Dark Messiah\n"; server_darkmessiah=true; } test_reg.close(); } //installs servers void install() { bool exit=false; while(!exit) { unsigned short int choice; cout << "\n\nServers available for install: \n"; cout << "1. Counter Strike Source\n"; cout << "2. Day of Defeat Source\n"; cout << "3. Day of Defeat Source Beta (not supported, please install manually)\n"; cout << "4. Garrys Mod\n"; cout << "5. Half Life 2 Deathmatch\n"; cout << "6. Team Fortress\n"; cout << "7. Counter Strike\n"; cout << "8. Counter Strike Condition Zero\n"; cout << "9. Death Match Classic\n"; cout << "10. Day of Defeat\n"; cout << "11. Opposing Force\n"; cout << "12. Ricochet\n"; cout << "13. Team Fortress Classic\n"; cout << "14. Dark Messiah\n"; cout << "15. EXIT to main menu\n"; cout << " : "; cin >> choice; cin.ignore(); switch(choice) { case 1: cout << "\n\nInstalling Counter Strike-Source Server...\nCreating directory...\n\n"; system("mkdir server_css"); system("./steam -command update -game \"Counter-Strike Source\" -dir server_css"); break; case 2: cout << "\n\nInstalling Day of Defeat Source Server...\nCreating directory...\n\n"; system("mkdir server_dods"); system("./steam -command update -game \"dods\" -dir server_dods"); break; case 4: cout << "\n\nInstalling Garrys Mod Server...\nCreating directory...\n\n"; system("mkdir server_garrysmod"); system("./steam -command update -game \"garrysmod\" -dir server_garrysmod"); break; case 5: cout << "\n\nInstalling Half Life 2 Deathmatch Server...\nCreating directory...\n\n"; system("mkdir server_hl2mp"); system("./steam -command update -game \"hl2mp\" -dir server_hl2mp"); break; case 6: cout << "\n\nInstalling Team Fortress Server...\nCreating directory...\n\n"; system("mkdir server_tf"); system("./steam -command update -game \"tf\" -dir server_tf"); break; case 7: cout << "\n\nInstalling Counter Strike Server...\nCreating directory...\n\n"; system("mkdir server_cs"); system("./steam -command update -game \"cstrike\" -dir server_cs"); break; case 8: cout << "\n\nInstalling Counter Strike Condition Zero Server...\nCreating directory...\n\n"; system("mkdir server_czero"); system("./steam -command update -game \"czero\" -dir server_czero"); break; case 9: cout << "\n\nInstalling Death Match Classic Server...\nCreating directory...\n\n"; system("mkdir server_dmc"); system("./steam -command update -game \"dmc\" -dir server_dmc"); break; case 10: cout << "\n\nInstalling Day of Defeat Server...\nCreating directory...\n\n"; system("mkdir server_dod"); system("./steam -command update -game \"dod\" -dir server_dod"); break; case 11: cout << "\n\nInstalling Opposing Force Server...\nCreating directory...\n\n"; system("mkdir server_gearbox"); system("./steam -command update -game \"gearbox\" -dir server_gearbox"); break; case 12: cout << "\n\nInstalling Ricochet(?) Server...\nCreating directory...\n\n"; system("mkdir server_ricochet"); system("./steam -command update -game \"ricochet\" -dir server_ricochet"); break; case 13: cout << "\n\nInstalling Team fortress Classic Server...\nCreating directory...\n\n"; system("mkdir server_tfc"); system("./steam -command update -game \"tfc\" -dir server_tfc"); break; case 14: cout << "\n\nInstalling Dark Messiah Server...\nCreating directory...\n\n"; system("mkdir server_darkmessiah"); system("./steam -command update -game \"darkmessiah\" -dir server_darkmessiah"); break; case 15: exit=true; break; default: cout << "\n\nTry again;)\n\n"; break; } } } //adjustements for server void param_choice() { char temp[200]; char choice; param[0] = 0; cout << "\n\nDisable Valve Anti Cheat System?(y|n) "; cin >> choice; cin.ignore(); if(choice == 'y') { strcat(param, "-insecure "); } cout <<"\n\nDisable bots?(y|n) "; cin >> choice; cin.ignore(); if(choice == 'y') { strcat(param, "-nobots "); } cout << "\n\nSpecify IP?(y|n) "; cin >> choice; cin.ignore(); if(choice == 'y') { cout <<"\n\nIP: "; cin.getline(temp, 100); // cin.ignore(); strcat(param, "-ip "); strcat(param, temp); strcat(param, " "); } cout << "\n\nSpecify port?(y|n) "; cin >> choice; cin.ignore(); if( choice=='y') { cout <<"\n\nPort: "; cin.getline(temp, 100); strcat(param, "-port "); strcat(param, temp); strcat(param, " "); } // cin.ignore(); cout << "\n\nMaximal Players? "; cin.getline(temp, 200); strcat(param, "+maxplayers "); strcat(param, temp); strcat(param, " "); // cin.ignore(); cout << "\n\nWhich map? "; cin.getline(temp, 200); strcat(param, "+map "); strcat(param, temp); strcat(param, " "); // cin.ignore(); cout << "\n\nOnly Lan Server?(y|n) "; cin >> choice; cin.ignore(); if(choice=='y') { strcat(param, "+sv_lan 1 "); } cout << "\n\nSpecify hostname?(y|n) "; cin >> choice; cin.ignore(); if (choice == 'y') { cout << "\n\nHostname: "; cin.getline(temp, 100); strcat(param, "+hostname "); strcat(param, temp); } // cin.ignore(); } //here you can start a server void start() { cout << "\n\nWhich server should be started?\n\n"; is_installed(); char params[(sizeof("cd server_css && ./srcds_run ") + 500)]; unsigned short int choice; cout << " : "; cin >> choice; cin.ignore(); switch(choice) { case 1: if(server_css==true) { param_choice(); cout << "\n\nStarting Counter Strike-Source..."; strcpy(params, "cd server_css && ./srcds_run "); strcat(params, param); //cout << params; system(params); } else not_installed(); break; case 2: if(server_dods==true) { param_choice(); strcpy(params, "cd server_dods && ./srcds_run "); strcat(params, param); cout << "\n\nStarting Day of Defeat Source..."; //cout << params; system(params); } else not_installed(); break; case 4: if(server_garrysmod==true) { param_choice(); strcpy(params, "cd server_garrysmod && ./srcds_run "); strcat(params, param); //cout << params; cout << "\n\nStarting Garrys Mod..."; system(params); } else not_installed(); break; case 5: if(server_hl2mp==true) { param_choice(); strcpy(params, "cd server_hl2mp && ./srcds_run "); strcat(params, param); //cout << params; cout << "\n\nStarting Half Life 2 Death Match..."; system(params); } else not_installed(); break; case 6: if(server_tf==true) { param_choice(); strcpy(params, "cd server_tf && ./srcds_run "); strcat(params, param); //cout << params; cout << "\n\nStarting Team Fortress..."; system(params); } else not_installed(); break; case 7: if(server_cs==true) { param_choice(); strcpy(params, "cd server_cs && ./srcds_run "); strcat(params, param); //cout << params; cout << "\n\nStarting Counter Strike..."; system(params); } else not_installed(); break; case 8: if(server_czero==true) { param_choice(); strcpy(params, "cd server_czero && ./srcds_run "); strcat(params, param); //cout << params; cout << "\n\nStarting Counter Strike Condition Zero..."; system(params); } else not_installed(); break; case 9: if(server_dmc==true) { param_choice(); strcpy(params, "cd server_dmc && ./srcds_run "); strcat(params, param); //cout << params; cout << "\n\nStarting Death Match Classic..."; system(params); } else not_installed(); break; case 10: if(server_dod==true) { param_choice(); strcpy(params, "cd server_dod && ./srcds_run "); strcat(params, param); //cout << params; cout << "\n\nStarting Day of Defeat..."; system(params); } else not_installed(); break; case 11: if(server_gearbox==true) { param_choice(); strcpy(params, "cd server_gearbox && ./srcds_run "); strcat(params, param); //cout << params; cout << "\n\nStarting Opposing Force..."; system(params); } else not_installed(); break; case 12: if(server_ricochet==true) { param_choice(); strcpy(params, "cd server_ricochet && ./srcds_run "); strcat(params, param); //cout << params; cout << "\n\nStarting ricochet..."; system(params); } else not_installed(); break; case 13: if(server_tfc==true) { param_choice(); strcpy(params, "cd server_tfc && ./srcds_run "); strcat(params, param); //cout << params; cout << "\n\nStarting Team Fortress Classic..."; system(params); } else not_installed(); break; case 14: if(server_darkmessiah==true) { param_choice(); strcpy(params, "cd server_darkmessiah && ./srcds_run "); strcat(params, param); //cout << params; cout << "\n\nStarting Dark Messiah..."; system(params); } else not_installed(); break; default: cout << "\n\nTry again ;)\n\n"; break; } } //here you can adjust and start your favorites #define OFF_N 0 #define OFF_C 1 void favorites() { char input[100][2][550]; int j; bool exit = false; unsigned short int choice; //read .favorites and save entrys in variables while(!exit) { j=-1; ifstream in; in.open(".favorites"); cout << "\n\nReading favorites...\n\n"; if(in.is_open()) { char temp[550]; while(!in.eof()) { in.getline(temp, 550); switch(temp[0]) { case 'n': if(temp[1] == ':') { j++; strcpy(input[j][OFF_N], &(temp[3])); } else cout << "Your .favorites is incorrupt, cannot understand: " << temp << "\nIgnoring...\n"; break; case 'c': if(temp[1] == ':') { strcpy(input[j][OFF_C], &(temp[3])); } else cout << "Your .favorites is incorrupt, cannot understand: " << temp << "\nIgnoring...\n"; break; default: if(temp[0] == 10 || temp[0]== 0) //10 menas new line 0 means end of string { //nothing to do } else cout << "Your .favorites is incorrupt, cannot understand: " << temp << "\nIgnoring...\n"; break; } if(j > 100) { never_happen(); cout << "\nToo many favorites (>100)\n"; break; } } } else { cout << "You have no favorites, please add one!\n\n"; } in.close(); //reading is finished, now user can adjust favorites unsigned short int choice; char params[(sizeof("cd server_tshb && ./srcds_run ") + 500)]; char name[100]; bool installed = false; //is set true when server is installed ofstream save; save.open(".favorites", ios_base::app); cout << "\n\n1. Add favorite\n"; cout << "2. Delete favorite\n"; cout << "3. Delte all favorites\n"; cout << "4. Start favorite\n"; cout << "5. Back to main menu\n"; cout << " : "; cin >> choice; switch(choice) { case 1: cout << "\n\nFrom which game should be the favorite?\n\n"; is_installed(); unsigned short int choice; cout << " : "; cin >> choice; cin.ignore(); switch(choice) { case 1: if(server_css==true) { strcpy(params, "cd server_css && ./srcds_run "); installed = true; } else not_installed(); break; case 2: if(server_dods==true) { strcpy(params, "cd server_dods && ./srcds_run "); installed = true; } else not_installed(); break; case 4: if(server_garrysmod==true) { strcpy(params, "cd server_garrysmod && ./srcds_run "); installed = true; } else not_installed(); break; case 5: if(server_hl2mp==true) { strcpy(params, "cd server_hl2mp && ./srcds_run "); installed = true; } else not_installed(); break; case 6: if(server_tf==true) { strcpy(params, "cd server_tf && ./srcds_run "); installed = true; } else not_installed(); break; case 7: if(server_cs==true) { strcpy(params, "cd server_cs && ./srcds_run "); installed = true; } else not_installed(); break; case 8: if(server_czero==true) { strcpy(params, "cd server_czero && ./srcds_run "); installed = true; } else not_installed(); break; case 9: if(server_dmc==true) { strcpy(params, "cd server_dmc && ./srcds_run "); installed = true; } else not_installed(); break; case 10: if(server_dod==true) { strcpy(params, "cd server_dod && ./srcds_run "); installed = true; } else not_installed(); break; case 11: if(server_gearbox==true) { strcpy(params, "cd server_gearbox && ./srcds_run "); installed = true; } else not_installed(); break; case 12: if(server_ricochet==true) { strcpy(params, "cd server_ricochet && ./srcds_run "); installed = true; } else not_installed(); break; case 13: if(server_tfc==true) { strcpy(params, "cd server_tfc && ./srcds_run "); installed = true; } else not_installed(); break; case 14: if(server_darkmessiah==true) { strcpy(params, "cd server_darkmessiah && ./srcds_run "); installed = true; } else not_installed(); break; default: cout << "\n\nTry again ;)\n\n"; break; } if(installed==true) { cout << "\n\nNow you should make a few adjustments for the favorite\n\n"; param_choice(); strcat(params, param); cout << "\n\nWhich name do you wish for this favorite? "; cin.getline(name, 100); //cin.ignore(); save << "n: " << name << endl; save << "c: " << params << endl; save.close(); } break; case 2: cout << "\n\nWhich favorite server do you want to delete?\n\n"; for (int i = 0; i<=j;i++) { cout << (i+1) << "\t" << input[i][OFF_N] << endl; } cout << " : "; cin >> choice; choice--; if(choice > j) { cout << "\n\nThis entry does not exist!"; } else { ofstream save_del; save_del.open(".favorites"); for (int i = 0;i<=j;i++) { if(i==choice) { //nothing to do } else { save_del << "n: " << input[i][OFF_N] << endl; save_del << "c: " << input[i][OFF_C] << endl; } } save_del.close(); } break; case 3: char temp; cout << "\n\nAll favorites are going to be deleted. Are you sure?(y|n) "; cin >> temp; if(temp=='y') { ofstream del_all; del_all.open(".favorites"); del_all.close(); } break; case 4: cout << "\n\nWhich favorite server do you want to start?\n\n"; for (int i = 0; i<=j;i++) { cout << (i+1) << "\t" << input[i][OFF_N] << endl; } cout << " : "; cin >> choice; choice--; if(choice > j) { cout << "\n\nThis entry does not exist!"; break; } else { cout << "\n\nStarting favorite..."; system(input[choice][OFF_C]); } break; case 5: exit=true; break; default: cout << "\n\nTry again ;)\n"; } save.close(); } } void copy_maps() { char params[550]; //here is saved the complete cp command cout << "\n\nInto which server do you want to copy the maps?"; is_installed(); unsigned short int choice; cout << " : "; cin >> choice; cin.ignore(); bool installed=false; //is set true when server is installed switch(choice) { case 1: if(server_css==true) { strcpy(params, "cd server_css/cstrike && "); installed = true; } else not_installed(); break; case 2: if(server_dods==true) { strcpy(params, "cd server_dods/orangebox/dod && "); installed = true; } else not_installed(); break; case 4: if(server_garrysmod==true) { strcpy(params, "cd server_garrysmod/orangebox && "); installed = true; } else not_installed(); break; case 5: if(server_hl2mp==true) { strcpy(params, "cd server_hl2mp/hl2mp && "); installed = true; } else not_installed(); break; case 6: if(server_tf==true) { strcpy(params, "cd server_tf/orangebox/tf && "); installed = true; } else not_installed(); break; case 7: if(server_cs==true) { strcpy(params, "cd server_cs/cstrike && "); installed = true; } else not_installed(); break; case 8: if(server_czero==true) { strcpy(params, "cd server_czero/czero && "); installed = true; } else not_installed(); break; case 9: if(server_dmc==true) { strcpy(params, "cd server_dmc/dmc && "); installed = true; } else not_installed(); break; case 10: if(server_dod==true) { strcpy(params, "cd server_dod/dod && "); installed = true; } else not_installed(); break; case 11: if(server_gearbox==true) { strcpy(params, "cd server_gearbox/gearbox && "); installed = true; } else not_installed(); break; case 12: if(server_ricochet==true) { strcpy(params, "cd server_ricochet/ricochet && "); installed = true; } else not_installed(); break; case 13: if(server_tfc==true) { strcpy(params, "cd server_tfc/tfc && "); installed = true; } else not_installed(); break; case 14: if(server_darkmessiah==true) { strcpy(params, "cd server_darkmessiah && "); installed = true; } else not_installed(); break; default: cout << "\n\nTry again ;)\n\n"; break; } if(installed==true) { char temp[530]; cout << "\n\nWhere are the maps? "; cin.getline(temp, 500); strcat(params, "cp -v "); strcat(params, temp); strcat(params, "/* maps/ "); system(params); //cin.ignore(); } } void edit_mapcl(int x) { //x=1 to edit maplist.txt //x=2 to edit mapcycle.txt //x=3 to edit votemaplist.txt (only with mani admin plugin) char params[60]; cout << "\n\nFrom which server do you want to edit the "; if(x==1) cout << "maplist?"; if(x==2) cout << "mapcycle?"; if(x==3) cout << "votemaplist.txt?"; is_installed(); unsigned short int choice; cout << " : "; cin >> choice; cin.ignore(); bool installed=false; //is set true when server is installed switch(choice) { case 1: if(server_css==true) { strcpy(params, "server_css/cstrike"); installed = true; } else not_installed(); break; case 2: if(server_dods==true) { strcpy(params, "server_dods/orangebox/dod"); installed = true; } else not_installed(); break; case 4: if(server_garrysmod==true) { strcpy(params, "server_garrysmod/orangebox"); installed = true; } else not_installed(); break; case 5: if(server_hl2mp==true) { strcpy(params, "server_hl2mp/hl2mp"); installed = true; } else not_installed(); break; case 6: if(server_tf==true) { strcpy(params, "server_tf/orangebox/tf"); installed = true; } else not_installed(); break; case 7: if(server_cs==true) { strcpy(params, "server_cs/cstrike"); installed = true; } else not_installed(); break; case 8: if(server_czero==true) { strcpy(params, "server_czero/czero"); installed = true; } else not_installed(); break; case 9: if(server_dmc==true) { strcpy(params, "server_dmc/dmc"); installed = true; } else not_installed(); break; case 10: if(server_dod==true) { strcpy(params, "server_dod/dod"); installed = true; } else not_installed(); break; case 11: if(server_gearbox==true) { strcpy(params, "server_gearbox/gearbox"); installed = true; } else not_installed(); break; case 12: if(server_ricochet==true) { strcpy(params, "server_ricochet/ricochet"); installed = true; } else not_installed(); break; case 13: if(server_tfc==true) { strcpy(params, "server_tfc/tfc"); installed = true; } else not_installed(); break; case 14: if(server_darkmessiah==true) { strcpy(params, "server_darkmessiah"); installed = true; } else not_installed(); break; default: cout << "\n\nTry again ;)\n\n"; break; } if(installed==true) { char mapfolder[70]; strcpy(mapfolder, params); strcat(mapfolder, "/maps/"); if (x==1) { strcat(params, "/maplist.txt"); } if(x==2) { strcat(params, "/mapcycle.txt"); } if(x==3) { strcat(params, "/cfg/mani_admin_plugin/votemaplist.txt"); } bool exit =false; while(!exit) { if((x !=1) && (x !=2) && x !=3) { never_happen(); break; } if (x==1) { cout << "\n\nHere is your current maplist: \n\n"; } if(x==2) { cout << "\n\nHere is your current mapcycle: \n\n"; } if(x==3) { cout << "\n\nHere is your current votemaplist: \n\n"; } //x=1 to edit maplist.txt //x=2 to edit mapcycle.txt //x=3 to edit votemaplist.txt (only with mani admin plugin) ifstream input; //to read current *.txt input.open(params); ofstream output; //to add a new entry output.open(params, ios_base::app); char maps[350][50]; unsigned int i; i=0; if(input.is_open()) { while(!input.eof()) { input.getline(maps[i], 50); if(maps[i][0] == 10 || maps[i][0] == 0) //10 means new line, 0 means end of string { //nothing to do } else { cout << (i+1) << ".\t" << maps[i] << endl; i++; } } } else { cout << "\nNo maps. Please add one\n"; } input.close(); unsigned short int choice; cout << "\n\n1. Add a map\n"; cout << "2. Delete a map\n"; cout << "3. Copy all maps from map folder\n"; cout << "4. Delete all maps\n"; cout << "5. Back \n"; cout << " : "; cin >> choice; cin.ignore(); char temp[50]; switch(choice) { case 1: cout << "\n\nName of map? "; cin.getline(temp, 50); output << endl << temp; break; case 2: cout << "\n\nWhich map do you wish to delete? "; unsigned int choice; cin >> choice; choice--; if (choice >= i) { cout << "\n\nThis entry does not exist!\n"; } else { ofstream save_del; save_del.open(params); for (int y = 0; y temp.txt"); system(temp); { ifstream in_temp; in_temp.open("temp.txt"); ofstream out; out.open(params); if(in_temp.is_open()) { while(!in_temp.eof()) { in_temp.getline(temp, 200); if(!strncmp(temp, map, strlen(map))) { continue; } if(!strcmp(temp, "materials")) { continue; } if(!strcmp(temp, "graphs")) { continue; } if(!strcmp(temp, "soundcache")) { continue; } for(int i=0; i <= strlen(temp); i++) { int k = 0; switch(temp[i]) { case '.': k=1; break; default: map[i]=temp[i]; break; } if(k==1) { map[i]=0; //0 means end of string break; } } out << map << endl; } } else { never_happen(); cout << "Cannot open temp.txt"; } in_temp.close(); out.close(); } system("rm -rf temp.txt"); break; case 4: char tempi; cout << "\n\nAll the maps are going to be deleted. Are you sure?(y|n) "; cin >> tempi; if(tempi=='y') { ofstream del_all; del_all.open(params); del_all.close(); } break; case 5: exit=true; break; default: cout << "\n\nWrong choice. Try again ;)"; break; } output.close(); //closing file to add a new entry } } } void install_mani() { cout << "\n\nIn which server do you want to install mani asmin plugin?\n\n"; unsigned int choice; is_installed(); cout << "\n : "; char params[300]; //the hole command is saved here cin >> choice; cin.ignore(); bool installed=false; //is set true when server is installed switch(choice) { case 1: if(server_css==true) { strcpy(params, "cd server_css/cstrike && "); installed = true; } else not_installed(); break; case 2: if(server_dods==true) { strcpy(params, "cd server_dods/orangebox/dod && "); installed = true; } else not_installed(); break; case 4: if(server_garrysmod==true) { cout << "\nNot supported!"; } else not_installed(); break; case 5: if(server_hl2mp==true) { strcpy(params, "cd server_hl2mp/hl2mp && "); installed = true; } else not_installed(); break; case 6: if(server_tf==true) { strcpy(params, "cd server_tf/orangebox/tf && "); installed = true; } else not_installed(); break; case 7: if(server_cs==true) { strcpy(params, "cd server_cs/cstrike && "); installed = true; } else not_installed(); break; case 8: if(server_czero==true) { strcpy(params, "cd server_czero/czero && "); installed = true; } else not_installed(); break; case 9: if(server_dmc==true) { cout << "\nNot supported!"; } else not_installed(); break; case 10: if(server_dod==true) { strcpy(params, "cd server_dod/dod && "); installed = true; } else not_installed(); break; case 11: if(server_gearbox==true) { cout << "\nNot supported!"; } else not_installed(); break; case 12: if(server_ricochet==true) { cout << "\nNot supported!"; } else not_installed(); break; case 13: if(server_tfc==true) { cout << "\nNot supported!"; } else not_installed(); break; case 14: if(server_darkmessiah==true) { cout << "\nNot supported!"; } else not_installed(); break; default: cout << "\n\nTry again ;)\n\n"; break; } if(installed==true) { if (choice==6) { cout << endl << endl << "Downloading mani admin plugin with wget and unzipping archive..." << endl << endl; strcat (params, "wget -N http://www.mani-admin-plugin.com/mani_admin_plugin/v1_2_beta_s/mani_admin_plugin_v1_2_beta_s_orange.zip && "); //to download mani admin plugin strcat(params, "unzip -o mani_admin_plugin_v1_2_beta_s_orange.zip "); //to unzip mani amdin plugin (unzips automatically in right folder) system(params); } else { cout << endl << endl << "Downloading mani admin plugin with wget and unzipping archive..." << endl << endl; strcat (params, "wget -N http://www.mani-admin-plugin.com/mani_admin_plugin/v1_2_beta_s/mani_admin_plugin_v1_2_beta_s.zip && "); //to download mani admin plugin strcat(params, "unzip -o mani_admin_plugin_v1_2_beta_s.zip "); //to unzip mani amdin plugin (unzips automatically in right folder) system(params); } ofstream save_vdf; cout << "\n\nCreating mani_admin_plugin.vdf\n"; switch (choice) { case 1: save_vdf.open("server_css/cstrike/addons/mani_admin_plugin.vdf"); save_vdf << "\"Plugin\"\n"; save_vdf << "{\n"; save_vdf << " \"file\" \"../cstrike/addons/mani_admin_plugin\"\n"; save_vdf << "}"; break; case 2: save_vdf.open("server_dods/orangebox/dod/addons/mani_admin_plugin.vdf"); save_vdf << "\"Plugin\"\n"; save_vdf << "{\n"; save_vdf << " \"file\" \"../dod/addons/mani_admin_plugin\"\n"; save_vdf << "}"; break; case 5: save_vdf.open("server_hl2mp/hl2mp/addons/mani_admin_plugin.vdf"); save_vdf << "\"Plugin\"\n"; save_vdf << "{\n"; save_vdf << " \"file\" \"../hl2mp/addons/mani_admin_plugin\"\n"; save_vdf << "}"; break; case 6: save_vdf.open("server_tf/orangebox/tf/addons/mani_admin_plugin.vdf"); save_vdf << "\"Plugin\"\n"; save_vdf << "{\n"; save_vdf << " \"file\" \"../tf/addons/mani_admin_plugin\"\n"; save_vdf << "}"; break; case 7: save_vdf.open("server_cs/cstrike/addons/mani_admin_plugin.vdf"); save_vdf << "\"Plugin\"\n"; save_vdf << "{\n"; save_vdf << " \"file\" \"../cstrike/addons/mani_admin_plugin\"\n"; save_vdf << "}"; break; case 8: save_vdf.open("server_czero/czero/addons/mani_admin_plugin.vdf"); save_vdf << "\"Plugin\"\n"; save_vdf << "{\n"; save_vdf << " \"file\" \"../czero/addons/mani_admin_plugin\"\n"; save_vdf << "}"; break; case 10: save_vdf.open("server_dod/dod/addons/mani_admin_plugin.vdf"); save_vdf << "\"Plugin\"\n"; save_vdf << "{\n"; save_vdf << " \"file\" \"../dod/addons/mani_admin_plugin\"\n"; save_vdf << "}"; break; //case 13: break; //tfc default: never_happen(); break; } cout << "\n\nMani Admin Plugin succesfully installed!\n"; } } void deactivate_mani() { cout << "\n\nForm which server do you wish to deactivate mani admin plugin? \n"; is_installed(); unsigned short int choice; cout << "\n : "; cin >> choice; bool installed=false; //is set on true when server is installed char params[100]; switch(choice) { case 1: if(server_css==true) { strcpy(params, "cd server_css/cstrike && "); installed = true; } else not_installed(); break; case 2: if(server_dods==true) { strcpy(params, "cd server_dods/orangebox/dod && "); installed = true; } else not_installed(); break; case 4: if(server_garrysmod==true) { cout << "\nNot supported!"; } else not_installed(); break; case 5: if(server_hl2mp==true) { strcpy(params, "cd server_hl2mp/hl2mp && "); installed = true; } else not_installed(); break; case 6: if(server_tf==true) { strcpy(params, "cd server_tf/orangebox/tf && "); installed = true; } else not_installed(); break; case 7: if(server_cs==true) { strcpy(params, "cd server_cs/cstrike && "); installed = true; } else not_installed(); break; case 8: if(server_czero==true) { strcpy(params, "cd server_czero/czero && "); installed = true; } else not_installed(); break; case 9: if(server_dmc==true) { cout << "\nNot supported!"; } else not_installed(); break; case 10: if(server_dod==true) { strcpy(params, "cd server_dod/dod && "); installed = true; } else not_installed(); break; case 11: if(server_gearbox==true) { cout << "\nNot supported!"; } else not_installed(); break; case 12: if(server_ricochet==true) { cout << "\nNot supported!"; } else not_installed(); break; case 13: if(server_tfc==true) { cout << "\nNot supported!"; } else not_installed(); break; case 14: if(server_darkmessiah==true) { cout << "\nNot supported!"; } else not_installed(); break; default: cout << "\n\nTry again ;)\n\n"; break; } if(installed==true) { strcat(params, "rm -rf addons/mani_admin_plugin.vdf"); cout << "\n\nDeactivating mani admin plugin...\nDeleting mani_admin_plugin.vdf"; system(params); } } void mani_admins() { bool exit = false; char params[100]; cout << "\n\nFrom which server do you want to manage the admins?\n"; is_installed(); unsigned short int choice; cout << "\n : "; cin >> choice; bool installed=false; //is set true when server is installed switch(choice) { case 1: if(server_css==true) { strcpy(params, "server_css/cstrike"); installed = true; } else not_installed(); break; case 2: if(server_dods==true) { strcpy(params, "server_dods/orangebox/dod"); installed = true; } else not_installed(); break; case 4: if(server_garrysmod==true) { cout << "\nNot supported!"; } else not_installed(); break; case 5: if(server_hl2mp==true) { strcpy(params, "server_hl2mp/hl2mp"); installed = true; } else not_installed(); break; case 6: if(server_tf==true) { strcpy(params, "server_tf/orangebox/tf"); installed = true; } else not_installed(); break; case 7: if(server_cs==true) { strcpy(params, "server_cs/cstrike"); installed = true; } else not_installed(); break; case 8: if(server_czero==true) { strcpy(params, "server_czero/czero"); installed = true; } else not_installed(); break; case 9: if(server_dmc==true) { cout << "\nNot supported!"; } else not_installed(); break; case 10: if(server_dod==true) { strcpy(params, "server_dod/dod"); installed = true; } else not_installed(); break; case 11: if(server_gearbox==true) { cout << "\nNot supported!"; } else not_installed(); break; case 12: if(server_ricochet==true) { cout << "\nNot supported!"; } else not_installed(); break; case 13: if(server_tfc==true) { cout << "\nNot supported!"; } else not_installed(); break; case 14: if(server_darkmessiah==true) { cout << "\nNot supported!"; } else not_installed(); break; default: cout << "\n\nTry again ;)\n\n"; break; } if(installed==true) { //copy old adminlist to the new one! char temp[200]; strcpy(temp, "cd "); strcat(temp, params); strcat(temp, " && "); strcat(temp, "cp cfg/mani_admin_plugin/adminlist.txt.old cfg/mani_admin_plugin/adminlist.txt"); system(temp); strcat(params, "/cfg/mani_admin_plugin/adminlist.txt"); cout << endl << endl; while (!exit) { char input[50][2][200]; //OFF_N = 0, means name; OFF_C = 1, means steam id or ip ifstream in; in.open(params); int counter = 0; if(in.is_open()) { cout << "\n\nCurrent admins: \n"; while(!in.eof()) { char temp[200]; in.getline(temp, 200); switch(temp[0]) { case 'S': if(!strncmp(temp, "STEAM", 5)) { strcpy(input[counter][OFF_C], temp); } else cout << "\n\nCannot understand: " << temp << "\nIgnoring..."; break; case ';': strcpy(input[counter][OFF_C], temp); break; case '/': if(!strncmp(temp, "//n: ", 5)) { strcpy(input[counter][OFF_N], &temp[4]); cout << (counter+1) << ".\t" << input[counter][OFF_N] << endl; counter++; } break; default: if(temp[0] == 10 || temp[0]== 0) //10 menas new line 0 means end of string { //nothing to do } else cout << "\n\nCannot understand: " << temp << "\nIgnoring..."; } } } else { cout << "\nNo admins. Please add one\n"; } in.close(); cout << "\n\n1. Add admin\n"; cout << "2. Delete admin\n"; cout << "3. Delte all admins\n"; cout << "4. Exit\n"; cout << " : "; cin >> choice; cin.ignore(); char temp[200]; ofstream out; out.open(params, ios_base::app); switch(choice) { case 1: cout << "\n\nSteam ID or IP of the player? "; cin.getline(temp, 200); //test if steam id or ip if(!strncmp(temp, "STEAM", 5)) { out << endl << temp << endl; } else { out << endl<< ";"<< temp << endl; } cout << "\nName of the player? "; cin.getline(temp, 200); out << "//n: " << temp; break; case 2: cout << "\n\nWhich admin do you want do delete? "; cin >> choice; choice--; if(choice > counter) { cout << "\nThis entry does not exist!\n\n"; } else { ofstream save_del; save_del.open(params); for (int i = 0;i<=counter;i++) { if(i==choice) { //nothing to do } else { save_del << endl << input[i][OFF_C] ; save_del << "//n: " << input[i][OFF_C] << endl; } } save_del.close(); } break; case 3: char temp; cout << "\n\nAll favorites are going to be deleted. Are you sure?(y|n) "; cin >> temp; if(temp=='y') { ofstream del_all; del_all.open(params); del_all.close(); } break; case 4: exit=true; break; default: cout << "\n\nTry again;)\n\n"; break; } out.close(); } } } void mani_wordfilter() { bool exit=false; char params[100]; cout << "\n\nFrom which server do you want to manage the admins?\n"; is_installed(); unsigned short int choice; cout << "\n : "; cin >> choice; bool installed=false; //is set true when server is installed switch(choice) { case 1: if(server_css==true) { strcpy(params, "server_css/cstrike"); installed = true; } else not_installed(); break; case 2: if(server_dods==true) { strcpy(params, "server_dods/orangebox/dod"); installed = true; } else not_installed(); break; case 4: if(server_garrysmod==true) { cout << "\nNot supported!"; } else not_installed(); break; case 5: if(server_hl2mp==true) { strcpy(params, "server_hl2mp/hl2mp"); installed = true; } else not_installed(); break; case 6: if(server_tf==true) { strcpy(params, "server_tf/orangebox/tf"); installed = true; } else not_installed(); break; case 7: if(server_cs==true) { strcpy(params, "server_cs/cstrike"); installed = true; } else not_installed(); break; case 8: if(server_czero==true) { strcpy(params, "server_czero/czero"); installed = true; } else not_installed(); break; case 9: if(server_dmc==true) { cout << "\nNot supported!"; } else not_installed(); break; case 10: if(server_dod==true) { strcpy(params, "server_dod/dod"); installed = true; } else not_installed(); break; case 11: if(server_gearbox==true) { cout << "\nNot supported!"; } else not_installed(); break; case 12: if(server_ricochet==true) { cout << "\nNot supported!"; } else not_installed(); break; case 13: if(server_tfc==true) { cout << "\nNot supported!"; } else not_installed(); break; case 14: if(server_darkmessiah==true) { cout << "\nNot supported!"; } else not_installed(); break; default: cout << "\n\nTry again ;)\n\n"; break; } if(installed==true) { strcat(params, "/cfg/mani_admin_plugin/wordfilter.txt"); char filter[200][50]; int counter = 0; while(!exit) { int counter = 0; ifstream in; in.open(params); cout << "\nhere is your wordfilter: \n"; if(in.is_open()) { while (!in.eof()) { char temp[50]; in.getline(temp, 50); switch(temp[0]) { case '/': //nothing to do break; case 10: //nothing to do (10 means new line) break; case 0: //nothing to do (0 means end of string) break; default: strcpy(filter[counter], temp); cout << (counter + 1) << "\t" << filter[counter] << endl; counter++; break; } } } else cout << "\nNo wordfilters. Please add one!\n"; cout << "\n\n1. Add word\n"; cout << "2. Delete word\n"; cout << "3. Delte complete wordfilter\n"; cout << "4. Exit\n"; cout << " : "; cin >> choice; cin.ignore(); switch (choice) { case 1: cout << "\nWord: "; { char temp[50]; cin.getline(temp, 50); ofstream out; out.open(params, ios_base::app); out << endl << temp; out.close(); } break; case 2: cout << "\n\nWhich word do you want do delete? "; cin >> choice; choice--; if(choice > counter) { cout << "\nThis entry does not exist!\n\n"; } else { ofstream save_del; save_del.open(params); for (int i = 0;i<=counter;i++) { if(i==choice) { //nothing to do } else { save_del << endl << filter[i]; } } save_del.close(); } break; case 3: char temp; cout << "\n\nThe hole wordfilter is going to be deleted. Are you sure?(y|n) "; cin >> temp; if(temp=='y') { ofstream del_all; del_all.open(params); del_all.close(); } break; case 4: exit=true; break; default: cout << "\n\nTry again;)\n\n"; break; } } } } void config_mani() { bool exit = false; while(!exit) { cout << "\n\n1. Install mani admin plugin\n"; cout << "2. Deactivate mani admin plugin\n"; cout << "3. Configurate Admins\n"; cout << "4. Configurate votemapslist\n"; cout << "5. Configurate wordfilter\n"; cout << "6. Exit\n"; cout << " : "; unsigned short int choice; cin >> choice; cin.ignore(); switch (choice) { case 1: install_mani(); break; case 2: deactivate_mani(); break; case 3: mani_admins(); break; case 4: edit_mapcl(3); break; case 5: mani_wordfilter(); break; case 6: exit = true; break; default: cout << "\n\nTry again;)\n"; } } } //here you can Configurate servers void config_server() { bool exit=false; while(!exit) { unsigned short int choice; cout << "\n\n1. Copy maps into server\n"; cout << "2. Edit maplist\n"; cout << "3. Edit mapcylce\n"; cout << "4. Configure mani admin plugin\n"; cout << "5. Exit to main menu\n"; cout << " : "; cin >> choice; switch(choice) { case 1: copy_maps(); break; case 2: edit_mapcl(1); //1 means edit maplist.txt break; case 3: edit_mapcl(2); //2 means edit mapcycle.txt break; case 4: config_mani(); break; case 5: exit=true; break; default: cout << "\n\nWrong choice. Try again;)"; break; } } } //here you can update the server with verifying all data! void update_server() { is_installed(); unsigned short int choice; cout << " : "; cin >> choice; cin.ignore(); switch(choice) { case 1: if(server_css==true) { cout << "\n\nUpdating Counter Strike-Source..."; system("./steam -command update -game \"Counter-Strike Source\" -dir server_css -verify_all"); } else not_installed(); break; case 2: if(server_dods==true) { cout << "\n\nUpdating Day of Defeat Source..."; system("./steam -command update -game \"dods\" -dir server_dods -verify_all"); } else not_installed(); break; case 5: if(server_hl2mp==true) { cout << "\n\nUpdating Half Life 2 Death Match..."; system("./steam -command update -game \"hl2mp\" -dir server_hl2mp -verify_all"); } else not_installed(); break; case 6: if(server_tf==true) { cout << "\n\nUpdating Team Fortress..."; system("./steam -command update -game \"tf\" -dir server_tf -verify_all"); } else not_installed(); break; case 7: if(server_cs==true) { cout << "\n\nUpdating Counter Strike..."; system("./steam -command update -game \"cs\" -dir server_cs -verify_all"); } else not_installed(); break; case 8: if(server_czero==true) { cout << "\n\nUpdating Counter Strike Condition Zero..."; system("./steam -command update -game \"czero\" -dir server_czero -verify_all"); } else not_installed(); break; case 9: if(server_dmc==true) { cout << "\n\nUpdating Death Match Classic..."; system("./steam -command update -game \"dmc\" -dir server_dmc -verify_all"); } else not_installed(); break; case 10: if(server_dod==true) { cout << "\n\nUpdating Day of Defeat..."; system("./steam -command update -game \"dod\" -dir server_dod -verify_all"); } else not_installed(); break; case 11: if(server_gearbox==true) { cout << "\n\nUpdating Opposing Force..."; system("./steam -command update -game \"gearbox\" -dir server_gearbox -verify_all"); } else not_installed(); break; case 12: if(server_ricochet==true) { cout << "\n\nUpdating ricochet..."; system("./steam -command update -game \"ricochet\" -dir server_ricochet -verify_all"); } else not_installed(); break; case 13: if(server_tfc==true) { cout << "\n\nUpdating Team Fortress Classic..."; system("./steam -command update -game \"tfc\" -dir server_tfc -verify_all"); } else not_installed(); break; case 14: if(server_darkmessiah==true) { cout << "\n\nUpdating Dark Messiah..."; system("./steam -command update -game \"darkmessiah\" -dir server_darkmessiah -verify_all"); } else not_installed(); break; default: cout << "\n\nTry again ;)\n\n"; break; } } //to update the client void update_client() { cout << "Updating Steam Linux Client\n\n"; system("./steam -command update"); cout << "\n\nUpdated\n\n"; } //main menu int main(int argc, char *argv[]) { char choice; cout << "steamserverutil v0.23 by MJ, hanfman_cool@web.de\n\n" << endl; ifstream test_file; test_file.open("hldsupdatetool.bin"); if(test_file.is_open()) { cout << "found hldsupdatetool.bin\n"; } else { cout << "downloading hldsupdatetool.bin with wget\n\n"; system("wget http://www.steampowered.com/download/hldsupdatetool.bin"); system("chmod +x hldsupdatetool.bin"); } test_file.close(); test_file.open("steam"); if( !test_file.is_open() ) { cout << "\n\nFirst you have to accept the license agreement, show now?(y|n) "; cin >> choice; cout << "\n\n"; if (choice == 'y') { system("./hldsupdatetool.bin"); } else { cout << "Aborting...\n"; return 0; } } test_file.close(); test_file.open("steam"); if( test_file.is_open()) { cout << "\nfound steam\n\n"; bool exit=false; while(!exit) { unsigned int menu; cout << "\n\n\t**main menu**\n"; cout << "1. Install or update game server\n"; cout << "2. Start game server\n"; cout << "3. Favorites\n"; cout << "4. Configurate servers\n"; cout << "5. Update game servers (verifys all data!)\n"; cout << "6. Update Steam Linux Client (recommend for first use)\n"; cout << "7. Exit\n"; cout << " : "; cin >> menu; cin.ignore(); switch (menu) { case 1: install(); break; case 2: start(); break; case 3: favorites(); break; case 4: config_server(); break; case 5: update_server(); break; case 6: update_client(); break; case 7: exit=true; break; default: cout << "Try again ;)"; break; } } } else { never_happen(); cout << "\nUnknown Error!\n"; } return 0; }