some tinkering around
authorPerttu Ahola <celeron55@gmail.com>
Sat, 25 Dec 2010 01:33:38 +0000 (03:33 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Sat, 25 Dec 2010 01:33:38 +0000 (03:33 +0200)
Makefile
src/main.cpp
src/server.cpp

index a6e360f3f33a40bad68b6ba4cc8c6bbe52c5193e..5f4195f96fa074c314ed9ddf35aaa0e00ca93be0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 # Makefile for Irrlicht Examples\r
 # It's usually sufficient to change just the target name and source file list\r
 # and be sure that CXX is set to a valid compiler\r
-SOURCE_FILES = materials.cpp guiTextInputMenu.cpp guiInventoryMenu.cpp irrlichtwrapper.cpp guiPauseMenu.cpp defaultsettings.cpp mapnode.cpp tile.cpp voxel.cpp mapblockobject.cpp inventory.cpp debug.cpp serialization.cpp light.cpp filesys.cpp connection.cpp environment.cpp client.cpp server.cpp socket.cpp mapblock.cpp mapsector.cpp heightmap.cpp map.cpp player.cpp utility.cpp main.cpp test.cpp\r
+SOURCE_FILES = guiMessageMenu.cpp materials.cpp guiTextInputMenu.cpp guiInventoryMenu.cpp irrlichtwrapper.cpp guiPauseMenu.cpp defaultsettings.cpp mapnode.cpp tile.cpp voxel.cpp mapblockobject.cpp inventory.cpp debug.cpp serialization.cpp light.cpp filesys.cpp connection.cpp environment.cpp client.cpp server.cpp socket.cpp mapblock.cpp mapsector.cpp heightmap.cpp map.cpp player.cpp utility.cpp main.cpp test.cpp\r
 \r
 DEBUG_TARGET = debugtest\r
 DEBUG_SOURCES = $(addprefix src/, $(SOURCE_FILES))\r
index 03d194d714996657e8c58511518d38e7ab57c05b..bea0d8e627e6aca65f2c318bdcecb7f91988dd60 100644 (file)
@@ -245,6 +245,7 @@ TODO: Transferring of the table from server to client
 #include "guiInventoryMenu.h"\r
 #include "guiTextInputMenu.h"\r
 #include "materials.h"\r
+//#include "guiMessageMenu.h"\r
 \r
 IrrlichtWrapper *g_irrlicht;\r
 \r
@@ -1537,10 +1538,15 @@ int main(int argc, char *argv[])
        // Test the text input system\r
        /*(new GUITextInputMenu(guienv, guiroot, -1, &g_active_menu_count,\r
                        NULL))->drop();*/\r
-       \r
+       /*GUIMessageMenu *menu =\r
+                       new GUIMessageMenu(guienv, guiroot, -1, \r
+                               &g_active_menu_count,\r
+                               L"Asd");\r
+       menu->drop();*/\r
+               \r
        // Launch pause menu\r
-       (new GUIPauseMenu(guienv, guiroot, -1, g_device,\r
-                       &g_active_menu_count))->drop();\r
+       /*(new GUIPauseMenu(guienv, guiroot, -1, g_device,\r
+                       &g_active_menu_count))->drop();*/\r
 \r
        // First line of debug text\r
        gui::IGUIStaticText *guitext = guienv->addStaticText(\r
@@ -1565,6 +1571,7 @@ int main(int argc, char *argv[])
                        L"Chat here\nOther line\nOther line\nOther line\nOther line",\r
                        core::rect<s32>(70, 60, 795, 150),\r
                        false, true);\r
+       chat_guitext->setBackgroundColor(video::SColor(96,0,0,0));\r
        core::list<ChatLine> chat_lines;\r
        \r
        /*\r
@@ -1574,6 +1581,9 @@ int main(int argc, char *argv[])
        u32 beginscenetime = 0;\r
        u32 scenetime = 0;\r
        u32 endscenetime = 0;\r
+       \r
+       // A test\r
+       //throw con::PeerNotFoundException("lol");\r
 \r
        /*\r
                Main loop\r
@@ -2353,7 +2363,7 @@ int main(int argc, char *argv[])
                                        i != chat_lines.end(); i++)\r
                        {\r
                                (*i).age += dtime;\r
-                               if((*i).age > 60.0)\r
+                               if((*i).age > 300.0)\r
                                {\r
                                        to_be_removed_count++;\r
                                        continue;\r
@@ -2530,6 +2540,29 @@ int main(int argc, char *argv[])
        catch(con::PeerNotFoundException &e)\r
        {\r
                dstream<<DTIME<<"Connection timed out."<<std::endl;\r
+               \r
+               /*if(g_device)\r
+               {\r
+                       GUIMessageMenu *menu =\r
+                                       new GUIMessageMenu(guienv, guiroot, -1, \r
+                                               &g_active_menu_count,\r
+                                               L"Connection timed out");\r
+\r
+                       video::IVideoDriver* driver = g_device->getVideoDriver();\r
+                       \r
+                       dstream<<"Created menu"<<std::endl;\r
+\r
+                       while(g_device->run() && menu->getStatus() == false)\r
+                       {\r
+                               driver->beginScene(true, true, video::SColor(255,0,0,0));\r
+                               guienv->drawAll();\r
+                               driver->endScene();\r
+                       }\r
+                       \r
+                       dstream<<"Dropping menu"<<std::endl;\r
+\r
+                       menu->drop();\r
+               }*/\r
        }\r
 #if CATCH_UNHANDLED_EXCEPTIONS\r
        /*\r
index 3bdabdfa66c83d6c38380d9631a8584517d0d165..e210d4d64dd87e94485f5e7058fd1bc7ca7aee08 100644 (file)
@@ -2313,6 +2313,11 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
 
                dstream<<"CHAT: "<<wide_to_narrow(message)<<std::endl;
 
+               // Get player name of this client
+               std::wstring name = narrow_to_wide(player->getName());
+
+               std::wstring line = std::wstring(L"<")+name+L"> "+message;
+               
                /*
                        Send the message to all other clients
                */
@@ -2330,14 +2335,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                        if(peer_id == client->peer_id)
                                continue;
 
-                       // Get player name of this client
-                       std::wstring name = L"unknown";
-                       Player *player = m_env.getPlayer(client->peer_id);
-                       if(player != NULL)
-                               name = narrow_to_wide(player->getName());
-                       
-                       SendChatMessage(client->peer_id,
-                                       std::wstring(L"<")+name+L"> "+message);
+                       SendChatMessage(client->peer_id, line);
                }
        }
        else