E:/Eigene Dateien/Eigene Projekte/c0re/c0re.cpp

Go to the documentation of this file.
00001 /*
00002         c0re is a multiplayer RTS on a hexagonal map with an evolving unit concept.
00003     Copyright (C) 2007 Stephan Hofmann
00004 
00005     This program is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 #include <fstream>
00019 
00020 #include "Level.h"
00021 #include "Menu.h"
00022 #include "Window.h"
00023 #include "Network.h"
00024 #include "myTools.h"
00025 
00026 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
00027 {
00028         // get all properties
00029         bool fullscreen = false;
00030         int width = 640;
00031         int height = 480;
00032         std::ifstream fin("c0re.cfg");
00033         std::string buffer;
00034         std::vector<std::string> values;
00035         while (fin.good()) {
00036                 std::getline(fin,buffer,'\n');
00037                 splitLine(values, buffer, "=");
00038                 if (values[0] == "fullscreen")
00039                 {
00040                         if (values[1] == "yes")
00041                                 fullscreen = true;
00042                 } 
00043                 else if (values[0] == "width")
00044                 {
00045                         width = atoi(values[1].c_str());
00046                         if (width < 1)
00047                                 width = 1;
00048                 }
00049                 else if (values[0] == "height")
00050                 {
00051                         height = atoi(values[1].c_str());
00052                         if (height < 1)
00053                                 height = 1;
00054                 }
00055         }
00056         fin.close();
00057 
00058         Window *wnd = new Window();                     //Window handle
00059         Level *level = new Level(wnd);          //create Level
00060         Menu * menu = new Menu(wnd);            //create Menu
00061         Network * net = 0;                                      //network object
00062 
00063         //no level selected first
00064         std::string level_name = "";
00065         std::string player_name = "";
00066 
00067         //display OGL-window
00068         wnd->createWindow("c0re", height, width, 32, fullscreen);
00069         //get game mode
00070         eGameMode gm = menu->getGameMode();
00071 
00072         switch (gm)
00073         {
00074                 case GM_Local:  
00075                                                 level_name = menu->getLevelName("maps", "*.map");
00076                                                 break;
00077                 case GM_Server: 
00078                                                 level_name = menu->getLevelName("maps", "*.map");
00079                                                 player_name = menu->getString("Playername", "UnnamedPlayer");
00080                                                 if (player_name == "")
00081                                                         level_name = "";
00082                                                 if (level_name != "")
00083                                                 {
00084                                                         net = new Network(level);
00085                                                         bool test = net->createServer(level_name, player_name);
00086                                                         int stop = 5;
00087                                                 }
00088                                                 break;
00089                 case GM_Client: 
00090                                                 std::string address = menu->getString("Verbindungsadresse","127.0.0.1");
00091                                                 if (address != "")
00092                                                 {
00093                                                         player_name = menu->getString("Playername", "UnnamedPlayer");
00094                                                         if (player_name != "")
00095                                                         {
00096                                                                 net = new Network(level);
00097                                                                 level_name = net->connect(player_name, address);
00098                                                         }
00099                                                 }
00100                                                 break;
00101         }
00102 
00103         if(level_name != "")
00104         {
00105                 level->load(level_name);
00106                 level->init();
00107                 if ((gm == GM_Server) || (gm == GM_Client))
00108                 {
00109                         if (!net->waitForRemoteSide())
00110                                 //return 1;
00111                         level->network = net;
00112                 }
00113                 level->run();
00114         }
00115 
00116         return 0;
00117 }
00118 

Generated on Tue Jul 17 22:02:22 2007 for C0re by  doxygen 1.5.2