--- xevil-2.02r2.orig/x11/draw.cpp +++ xevil-2.02r2/x11/draw.cpp @@ -34,6 +34,7 @@ // in Xvars instead. #include "viewport.h" +using namespace std; // Draw functions for World --- xevil-2.02r2.orig/x11/ui.cpp +++ xevil-2.02r2/x11/ui.cpp @@ -30,6 +30,7 @@ #include "utils.h" extern "C" { #include +#include #include #ifdef OPENWOUND_XOS_STRLEN_HACK #define _strings_h @@ -40,8 +41,8 @@ #include } -#include -#include +#include +#include #include "coord.h" #include "area.h" @@ -59,6 +60,7 @@ #include "panel.h" #include "viewport.h" +using namespace std; // Defines #define DEFAULT_BIG_FONT_NAME "-*-helvetica-*-r-*-*-18-*-*-*-*-*-*-*" @@ -226,20 +228,6 @@ for (int d = 0; d < xvars.dpyMax; d++) { xvars.alloc_named_color(d,"steelblue"); } - - // Run the license agreement. - // Note: The license agreement will not be run if the user runs - // "xevil -server -no_ui". - // Must be after init_x(). - Boolean reduceDraw = Viewport::get_reduce_draw(); - Boolean accepted = - LAgreement::check_accepted(largeViewport,smoothScroll,reduceDraw, - xvars,0,argc,argv); - Viewport::set_reduce_draw(reduceDraw); - if (!accepted) { - // Should probably let game.cpp call exit. - exit(1); - } // Ick, this should be in init_x(), but we need to call init_x() before // running the License Agreement to get this information. @@ -461,21 +449,27 @@ } } - if (down) { - // Restart game if space pressed. - // This doesn't always work, the otherInput flag might get cleared - // before it is used. - if (keycode == XKeysymToKeycode(xvars.dpy[dpyNum],XK_space)) { - otherInput = True; + // If function keys are assigned to movement, weapon or item functions, + // then this code will not get executed. + if (down && !found) { + // Pause Game + if (keycode == XKeysymToKeycode(xvars.dpy[dpyNum],XK_F1)) { + settingsChanges |= UIpause; + settings.pause = True; } - - if (!found) { - // Undocumented pause key feature. - // Don't do pause if XK_F1 is used for something else. - if (keycode == XKeysymToKeycode(xvars.dpy[dpyNum],XK_F1)) { - settingsChanges |= UIpause; - settings.pause = True; - } + // New Game + if (keycode == XKeysymToKeycode(xvars.dpy[dpyNum],XK_F2)) { + settingsChanges |= UInewGame; + } + // Change game style + if (keycode == XKeysymToKeycode(xvars.dpy[dpyNum],XK_F3)) { + settingsChanges |= UIstyle; + settings.style = (settings.style + 1) % NUM_GAME_STYLES; + + // Avoid the LEVELS_ONLY option. There was no button before + // I got here. Avoiding the ability to set it until I + // discover why + settings.style += (settings.style == LEVELS_ONLY) ? 1 : 0; } } } @@ -865,7 +859,7 @@ char *msg; if (msg = locator->message_deq()) { set_message(msg); - delete msg; + delete [] msg; messageTimer.set(MESSAGE_TIME); } } @@ -930,7 +924,7 @@ UiP ui = (UiP)closure; ui->settingsChanges |= UIenemiesRefill; // SGI compiler says you can't cast void* to Boolean. - Boolean val = (Boolean)(int)value; + Boolean val = (Boolean)(long)value; ui->settings.enemiesRefill = val; } @@ -939,7 +933,7 @@ void Ui::menu_controls_CB(void* value,Viewport* vPort,void* closure) { UiP ui = (UiP)closure; int dpyNum = vPort->get_dpy_num(); - Boolean val = (Boolean)(int)value; + Boolean val = (Boolean)(long)value; if (val) { XMapWindow(ui->xvars.dpy[dpyNum],ui->xdata.controls[dpyNum]); } @@ -955,13 +949,13 @@ Viewport* vPort,void* closure) { UiP ui = (UiP)closure; int dpyNum = vPort->get_dpy_num(); - Boolean active = (Boolean)(int)value; + Boolean active = (Boolean)(long)value; if (active) { ui->lControls[dpyNum].input = ui->lControls[dpyNum].key = ui->lControls[dpyNum].which = 0; - ostrstream str; + stringstream str; str << "There are 2 sets of controls for the players on the right and" << "\n" << "left sides of the keyboard, respectively." << "\n" @@ -979,10 +973,9 @@ << " player enter the " << (ui->lControls[dpyNum].which ? "second" : "first") << " key for <" << ui->keysNames[ui->lControls[dpyNum].key] - << ">." << ends; + << ">."; - ui->learnControls[dpyNum]->set_message(str.str()); - delete str.str(); + ui->learnControls[dpyNum]->set_message(str.str().c_str()); XMapWindow(ui->xvars.dpy[dpyNum],ui->xdata.learnControls[dpyNum]); } else { @@ -994,7 +987,7 @@ void Ui::menu_scenarios_CB(void* value,Viewport*,void* closure) { UiP ui = (UiP)closure; - Boolean val = (Boolean)(int)value; + Boolean val = (Boolean)(long)value; if (val) { ui->settingsChanges |= UIstyle; ui->settings.style = SCENARIOS; @@ -1005,7 +998,7 @@ void Ui::menu_levels_CB(void* value,Viewport*,void* closure) { UiP ui = (UiP)closure; - Boolean val = (Boolean)(int)value; + Boolean val = (Boolean)(long)value; if (val) { ui->settingsChanges |= UIstyle; ui->settings.style = LEVELS; @@ -1016,7 +1009,7 @@ void Ui::menu_kill_CB(void* value,Viewport*,void* closure) { UiP ui = (UiP)closure; - Boolean val = (Boolean)(int)value; + Boolean val = (Boolean)(long)value; if (val) { ui->settingsChanges |= UIstyle; ui->settings.style = KILL; @@ -1027,7 +1020,7 @@ void Ui::menu_duel_CB(void* value,Viewport*,void* closure) { UiP ui = (UiP)closure; - Boolean val = (Boolean)(int)value; + Boolean val = (Boolean)(long)value; if (val) { ui->settingsChanges |= UIstyle; ui->settings.style = DUEL; @@ -1038,7 +1031,7 @@ void Ui::menu_extended_CB(void* value,Viewport*,void* closure) { UiP ui = (UiP)closure; - Boolean val = (Boolean)(int)value; + Boolean val = (Boolean)(long)value; if (val) { ui->settingsChanges |= UIstyle; ui->settings.style = EXTENDED; @@ -1049,7 +1042,7 @@ void Ui::menu_training_CB(void* value,Viewport*,void* closure) { UiP ui = (UiP)closure; - Boolean val = (Boolean)(int)value; + Boolean val = (Boolean)(long)value; if (val) { ui->settingsChanges |= UIstyle; ui->settings.style = TRAINING; @@ -1070,7 +1063,7 @@ void Ui::menu_cooperative_CB(void* value,Viewport*,void* closure) { UiP ui = (UiP)closure; ui->settingsChanges |= UIcooperative; - Boolean val = (Boolean)(int)value; + Boolean val = (Boolean)(long)value; ui->settings.cooperative = val; } @@ -1079,7 +1072,7 @@ void Ui::menu_help_CB(void* value,Viewport* vPort,void* closure) { UiP ui = (UiP)closure; int dpyNum = vPort->get_dpy_num(); - Boolean active = (Boolean)(int)value; + Boolean active = (Boolean)(long)value; if (active) { XMapWindow(ui->xvars.dpy[dpyNum],ui->xdata.help[dpyNum]); @@ -1094,7 +1087,7 @@ void Ui::status_weapon_CB(void* value,Viewport* vPort,void*) { // Some mouse controls. // UiP ui = (UiP)closure; - int button = (int)value; + long button = (long)value; switch (button) { case Button1: @@ -1113,7 +1106,7 @@ void Ui::status_item_CB(void* value,Viewport* vPort,void*) { // UiP ui = (UiP)closure; - int button = (int)value; + long button = (long)value; switch (button) { case Button1: @@ -1167,14 +1160,14 @@ return; } - ostrstream str; + stringstream str; str << (ui->lControls[dpyNum].input ? "Left" : "Right") << " player: The " << (ui->lControls[dpyNum].which ? "second" : "first") << " key for <" << ui->keysNames[ui->lControls[dpyNum].key] << "> is " << XKeysymToString(XKeycodeToKeysym(ui->xvars.dpy[dpyNum], event->xkey.keycode,0)) - << "." << "\n" << "\n"; + << ".\n\n"; ui->keycodes[dpyNum][ui->lControls[dpyNum].input] [ui->lControls[dpyNum].key][ui->lControls[dpyNum].which] = event->xkey.keycode; @@ -1222,21 +1215,18 @@ << " player enter the " << (ui->lControls[dpyNum].which ? "second" : "first") << " key for <" << keysNames[ui->lControls[dpyNum].key] - << ">." << ends; + << ">."; // Add message in front of str.str(). - ostrstream fullStr; + stringstream fullStr; if (ui->lControls[dpyNum].input == UI_KEYS_LEFT) { fullStr << "You may dismiss this dialog now if you only want to" << "\n" - << "set the controls for one player." - << "\n" << "\n"; + << "set the controls for one player.\n\n"; } - fullStr << str.str() << ends; - delete str.str(); + fullStr << str.str(); - ui->learnControls[dpyNum]->set_message(fullStr.str()); - delete fullStr.str(); + ui->learnControls[dpyNum]->set_message(fullStr.str().c_str()); ui->controls_redraw(dpyNum); } @@ -1537,7 +1527,7 @@ Line::set_text_columns(HELP_COLS); Page page(NULL,helpMessage); const PtrList& lines = page.get_lines(); - ostrstream message; + stringstream message; for (int n = 0; n < lines.length(); n++) { Line* line = (Line*)lines.get(n); char* text = line->alloc_text(); @@ -1545,7 +1535,6 @@ message << text << '\n'; delete [] text; } - message << ends; for (int dpyNum = 0; dpyNum < xvars.dpyMax; dpyNum++) { @@ -1564,10 +1553,8 @@ new TextPanel(dpyNum,xvars,xdata.help[dpyNum],pos,size); assert(help[dpyNum]); - help[dpyNum]->set_message(message.str()); + help[dpyNum]->set_message(message.str().c_str()); } // dpyNum - - delete message.str(); } @@ -1621,7 +1608,7 @@ // Loop through all keys. for (int n = 0; n < UI_KEYS_MAX; n++) { // String for right side. - strstream str0; + stringstream str0; str0 << keysNames[n] << ": " << XKeysymToString(keymaps[0][n][0][0]); if (keymaps[0][n][0][1] && strlen(XKeysymToString(keymaps[0][n][0][1]))) str0 << ", " << XKeysymToString(keymaps[0][n][0][1]); @@ -1631,10 +1618,9 @@ && strlen(XKeysymToString(keymaps[0][n][1][1]))) str0 << ", " << XKeysymToString(keymaps[0][n][1][1]); } - str0 << ends; // String for left side. - strstream str1; + stringstream str1; str1 << keysNames[n] << ": " << XKeysymToString(keymaps[1][n][0][0]); if (keymaps[1][n][0][1] && strlen(XKeysymToString(keymaps[1][n][0][1]))) { str1 << ", " << XKeysymToString(keymaps[1][n][0][1]); @@ -1645,7 +1631,6 @@ && strlen(XKeysymToString(keymaps[1][n][1][1]))) str1 << ", " << XKeysymToString(keymaps[1][n][1][1]); } - str1 << ends; // Draw key on left side. if (n != IT_CHAT) { // Chat meaningless for left player. @@ -1653,16 +1638,14 @@ xvars.fontSize[dpyNum].width, xvars.font[dpyNum]->max_bounds.ascent + p * xvars.fontSize[dpyNum].height, - str1.str(),strlen(str1.str())); + str1.str().c_str(),str1.str().length()); } // Draw on right side. XDrawString(xvars.dpy[dpyNum],xdata.controls[dpyNum],xvars.gc[dpyNum], xvars.fontSize[dpyNum].width * (CONTROLS_COLS / 2 + 1), xvars.font[dpyNum]->max_bounds.ascent + (p++) * xvars.fontSize[dpyNum].height, - str0.str(),strlen(str0.str())); - delete str0.str(); - delete str1.str(); + str0.str().c_str(),str0.str().length()); } p++; --- xevil-2.02r2.orig/x11/viewport.cpp +++ xevil-2.02r2/x11/viewport.cpp @@ -44,8 +44,9 @@ #include #include } -#include +#include +using namespace std; #define TICK_BORDER_WIDTH 5 // border width big enough for a tick mark. #define TICK_WIDTH 3 @@ -60,14 +61,14 @@ #define COL_SHIFT 4 // Number of characters across for each menu button. -#define QUIT_LINE_LENGTH 5 -#define NEW_GAME_LINE_LENGTH 9 +#define QUIT_LINE_LENGTH 4 +#define NEW_GAME_LINE_LENGTH 13 #define HUMANS_NUM_LINE_LENGTH 9 #define ENEMIES_NUM_LINE_LENGTH 11 #define ENEMIES_REFILL_LINE_LENGTH 13 #define CONTROLS_LINE_LENGTH 13 #define LEARN_CONTROLS_LINE_LENGTH 12 -#define STYLE_LINE_LENGTH 11 +#define STYLE_LINE_LENGTH 16 #define SCENARIOS_LINE_LENGTH 9 #define LEVELS_LINE_LENGTH 6 #define KILL_LINE_LENGTH 16 @@ -1056,20 +1057,18 @@ void Viewport::set_menu_humans_num(int val) { assert(menusNum > menuHumansNum); - ostrstream str; - str << val << ends; - ((WritePanel *)menus[menuHumansNum])->set_value(str.str()); - delete str.str(); + stringstream str; + str << val; + ((WritePanel *)menus[menuHumansNum])->set_value(str.str().c_str()); } void Viewport::set_menu_enemies_num(int val) { assert(menusNum > menuEnemiesNum); - ostrstream str; - str << val << ends; - ((WritePanel *)menus[menuEnemiesNum])->set_value(str.str()); - delete str.str(); + stringstream str; + str << val; + ((WritePanel *)menus[menuEnemiesNum])->set_value(str.str().c_str()); } @@ -1128,10 +1127,9 @@ void Viewport::set_quanta(Quanta quanta) { assert(menusNum > menuQuanta); - ostrstream str; - str << quanta << ends; - ((WritePanel *)menus[menuQuanta])->set_value(str.str()); - delete str.str(); + stringstream str; + str << quanta; + ((WritePanel *)menus[menuQuanta])->set_value(str.str().c_str()); } @@ -1144,33 +1142,27 @@ void Viewport::set_humans_playing(int val) { - ostrstream msg; + stringstream msg; if (val == 1) { - msg << "1 Human" << ends; + msg << "1 Human"; } else { - msg << val << " Humans" << ends; + msg << val << " Humans"; } - char *msg_str = msg.str(); - - humansPlaying->set_message(msg_str); - delete msg_str; + humansPlaying->set_message(msg.str().c_str()); } void Viewport::set_enemies_playing(int val) { - ostrstream msg; + stringstream msg; if (val == 1) { - msg << "1 Enemy" << ends; + msg << "1 Enemy"; } else { - msg << val << " Enemies" << ends; + msg << val << " Enemies"; } - char *msg_str = msg.str(); - - enemiesPlaying->set_message(msg_str); - delete msg_str; + enemiesPlaying->set_message(msg.str().c_str()); } @@ -1632,7 +1624,7 @@ // Would be much better to put the radio-button logic in the Panel classes. if (pClosure->radio) { // SGI compiler says you can't cast void* to Boolean. - Boolean bValue = (Boolean)(int)value; + Boolean bValue = (Boolean)(long)value; if (!bValue) { ((TogglePanel*)panel)->set_value(True); } @@ -1701,7 +1693,7 @@ pos.y += xvars.fontSize[dpyNum].height; for (int n = 0; n < DIFFICULTY_LEVELS_NUM; n++) { - ostrstream str; + stringstream str; str << "[" << n; if (n == DIFF_NORMAL) { str << ",space] "; @@ -1709,10 +1701,9 @@ else { str << "] "; } - str << difficultyLevels[n].name << ends; + str << difficultyLevels[n].name; pos.y += xvars.fontSize[dpyNum].height; - draw_string(pos,str.str()); - delete str.str(); + draw_string(pos,str.str().c_str()); } XSetForeground(xvars.dpy[dpyNum],xvars.gc[dpyNum], @@ -1733,7 +1724,7 @@ -void Viewport::draw_string(const Pos &pos,char *msg) { +void Viewport::draw_string(const Pos &pos,const char *msg) { XDrawString(xvars.dpy[dpyNum],arena, xvars.gc[dpyNum], pos.x,pos.y + xvars.font[dpyNum]->max_bounds.ascent, @@ -1930,7 +1921,7 @@ new ButtonPanel(dpyNum,xvars,toplevel, pos,newGameUnit, Viewport::panel_callback,panelClosures.get(menuNewGame), - "New Game"); + "New Game (F2)"); assert(p); p->set_background(menuBg,False); pos.x += newGameUnit.width; @@ -2016,7 +2007,7 @@ new TextPanel(dpyNum,xvars,toplevel, pos,styleUnit, NULL,NULL, - "Game style:"); + "Game style: (F3)"); assert(p); // p->set_background(menuBg,False); pos.x += styleUnit.width; @@ -2194,33 +2185,24 @@ } const IntelStatus *status = intel->get_intel_status(); + statuses[statusName]->set_message(status->name); + + statuses[statusClassName]->set_message(status->className); - ostrstream name; - name << status->name << ends; - statuses[statusName]->set_message(name.str()); - delete name.str(); - - ostrstream className; - className << status->className << ends; - statuses[statusClassName]->set_message(className.str()); - delete className.str(); - - ostrstream health; + stringstream health; if (status->health == -1) { - health << "Dead" << ends; + health << "Dead"; } else { - health << status->health << " Health" << ends; + health << status->health << " Health"; } - statuses[statusHealth]->set_message(health.str()); - delete health.str(); + statuses[statusHealth]->set_message(health.str().c_str()); - ostrstream mass; - mass << status->mass << " Mass" << ends; - statuses[statusMass]->set_message(mass.str()); - delete mass.str(); + stringstream mass; + mass << status->mass << " Mass"; + statuses[statusMass]->set_message(mass.str().c_str()); - ostrstream weapon; + stringstream weapon; if (status->weaponClassId == A_None) { weapon << "No Weapon"; } @@ -2230,62 +2212,56 @@ if (status->ammo != PH_AMMO_UNLIMITED) { weapon << " (" << status->ammo << ")"; } - weapon << ends; statuses[statusWeapon]-> set_foreground(status->weaponReady ? xvars.green[dpyNum] : xvars.red[dpyNum],False); - statuses[statusWeapon]->set_message(weapon.str()); - delete weapon.str(); + statuses[statusWeapon]->set_message(weapon.str().c_str()); - ostrstream item; + stringstream item; if (status->itemClassId == A_None) { item << "No Item"; } else { item << status->item << " (" << status->itemCount << ")"; } - item << ends; - statuses[statusItem]->set_message(item.str()); - delete item.str(); + statuses[statusItem]->set_message(item.str().c_str()); - ostrstream livesHKills; + stringstream livesHKills; if (styleInfo->get_game_style_type() == EXTENDED) { // Takes soups into account. livesHKills << (status->humanKills - status->soups) - << " Human Kills" << ends; + << " Human Kills"; } else { if (status->lives == IT_INFINITE_LIVES) { // Does this case ever happen? I don't think so. - livesHKills << "Unlimited Lives" << ends; + livesHKills << "Unlimited Lives"; } else { if (status->lives == 1) { - livesHKills << "1 Life" << ends; + livesHKills << "1 Life"; } else { - livesHKills << status->lives << " Lives" << ends; + livesHKills << status->lives << " Lives"; } } } - statuses[statusLivesHKills]->set_message(livesHKills.str()); - delete livesHKills.str(); + statuses[statusLivesHKills]->set_message(livesHKills.str().c_str()); - ostrstream killsMKills; + stringstream killsMKills; if (styleInfo->get_game_style_type() == EXTENDED) { - killsMKills << status->enemyKills << " Machine Kills" << ends; + killsMKills << status->enemyKills << " Machine Kills"; } else { int kills = status->humanKills + status->enemyKills; if (kills == 1) { - killsMKills << "1 Kill" << ends; + killsMKills << "1 Kill"; } else { - killsMKills << kills << " Kills" << ends; + killsMKills << kills << " Kills"; } } - statuses[statusKillsMKills]->set_message(killsMKills.str()); - delete killsMKills.str(); + statuses[statusKillsMKills]->set_message(killsMKills.str().c_str()); } --- xevil-2.02r2.orig/x11/serverping.cpp +++ xevil-2.02r2/x11/serverping.cpp @@ -25,14 +25,15 @@ // code and should be reasonably easy to compile on Windows. -#include -#include +#include +#include #include "utils.h" #include "streams.h" #include "xetp_basic.h" #include "neth.h" #include "id.h" +using namespace std; class ServerPing { @@ -140,10 +141,9 @@ error("Error opening client UDP socket."); } - ostrstream str; - str << "Looking up IP address for server " << serverName << ends; - message(str.str()); - delete str.str(); + stringstream str; + str << "Looking up IP address for server " << serverName; + message(str.str().c_str()); // Create server address. memset((void *)&serverAddr,'\0',sizeof(serverAddr)); @@ -171,10 +171,9 @@ client.sin_addr.s_addr = htonl(INADDR_ANY); client.sin_port = htons((u_short)clientPort); if (bind(udpSock,(CMN_SOCKADDR *)&client,sizeof(client)) < 0) { - ostrstream str; - str << "Could not bind local UDP port " << clientPort << ends; - error(str.str()); - delete str.str(); + stringstream str; + str << "Could not bind local UDP port " << clientPort; + error(str.str().c_str()); return; } @@ -197,11 +196,10 @@ // Send "count" number of SERVER_PINGs. for (int tries = 0; tries < count; tries++) { // Send the ping. - ostrstream msg; + stringstream msg; msg << "Sending XETP::SERVER_PING to " - << serverName << ':' << serverPort << ends; - message(msg.str()); - delete msg.str(); + << serverName << ':' << serverPort; + message(msg.str().c_str()); XETPBasic::send_server_ping(udpOut); // Don't buffer the ping. udpOut->flush(); @@ -248,11 +246,10 @@ } // If we get here, we failed to reach the server. - ostrstream msg; + stringstream msg; msg << "No return from " << serverName << ':' << serverPort << " after " - << count << " tries." << ends; - error(msg.str()); - delete msg.str(); + << count << " tries."; + error(msg.str().c_str()); } @@ -271,12 +268,9 @@ void ServerPing::error(const char* msg1,const char* msg2) { - ostrstream str; - str << msg1 << msg2 << ends; - error(str.str()); - - // Will never get here, but WTF. - delete str.str(); + stringstream str; + str << msg1 << msg2; + error(str.str().c_str()); } --- xevil-2.02r2.orig/x11/l_agreement_dlg.cpp +++ xevil-2.02r2/x11/l_agreement_dlg.cpp @@ -31,7 +31,6 @@ #include } -#include #include "xdata.h" #include "panel.h" --- xevil-2.02r2.orig/x11/makefile +++ xevil-2.02r2/x11/makefile @@ -72,7 +72,7 @@ $(CC) $(DEBUG_OPT) $(ALL_CFLAGS) $(ALL_INCL_DIRS) -o $(OBJ_DIR)/serverping.o -c serverping.cpp $(OBJ_DIR)/serverping:: $(OBJ_DIR)/serverping.o - $(CC) $(LINK_FLAGS) $(LINK_OPT) $(LIBS_DIRS) -o $(OBJ_DIR)/serverping $(OBJ_DIR)/serverping.o $(OBJ_DIR)/utils.o $(OBJ_DIR)/xetp_basic.o $(OBJ_DIR)/streams.o $(OBJ_DIR)/id.o $(LIBS) + $(CC) $(LINK_FLAGS) $(LINK_OPT) $(LIBS_DIRS) -o $(OBJ_DIR)/serverping $(OBJ_DIR)/serverping.o $(OBJ_DIR)/utils.o $(OBJ_DIR)/xetp_basic.o $(OBJ_DIR)/streams.o $(OBJ_DIR)/id.o -lm # $(STRIP) $(OBJ_DIR)/serverping --- xevil-2.02r2.orig/x11/panel.cpp +++ xevil-2.02r2/x11/panel.cpp @@ -31,13 +31,14 @@ #include #include } -#include -#include +#include +#include #include "utils.h" #include "xdata.h" #include "panel.h" +using namespace std; #define PANEL_BORDER 1 #define PANEL_MARGAIN 2 @@ -311,15 +312,14 @@ void WritePanel::update_message() { - ostrstream tmp; + stringstream tmp; if (active) { - tmp << prompt << value << "_" << ends; + tmp << prompt << value << "_"; } else { - tmp << prompt << value << ends; + tmp << prompt << value; } - set_message(tmp.str()); - delete tmp.str(); + set_message(tmp.str().c_str()); } @@ -524,9 +524,8 @@ return; } - ostrstream tmp; - tmp << "CHAT <<" << value << "\nEnter to send, Esc to cancel." << ends; - TextPanel::set_message(tmp.str()); - delete tmp.str(); + stringstream tmp; + tmp << "CHAT <<" << value << "\nEnter to send, Esc to cancel."; + TextPanel::set_message(tmp.str().c_str()); } --- xevil-2.02r2.orig/x11/xdata.cpp +++ xevil-2.02r2/x11/xdata.cpp @@ -30,11 +30,12 @@ #include "xdata.h" #include "area.h" -#include +#include #include #include #include +using namespace std; // Means always allocate some color, even if it's really, really bad. @@ -47,9 +48,16 @@ int dpyNum,const Size& size, const char* title, long eventMask) { + + // Get Size of screen, so we can center Window + XWindowAttributes root_window_attributes; + XGetWindowAttributes(dpy[dpyNum],root[dpyNum], &root_window_attributes); + int left = (root_window_attributes.width - size.width) / 2; + int top = (root_window_attributes.height - size.height) / 3; + // Creates with 0 border width. Window toplevel = - XCreateSimpleWindow(dpy[dpyNum],root[dpyNum],0,0, + XCreateSimpleWindow(dpy[dpyNum],root[dpyNum],left,top, size.width,size.height, 0,windowBorder[dpyNum], windowBg[dpyNum]); --- xevil-2.02r2.orig/x11/main.cpp +++ xevil-2.02r2/x11/main.cpp @@ -25,6 +25,7 @@ #include "utils.h" extern "C" { +#include #include #ifdef OPENWOUND_XOS_STRLEN_HACK @@ -33,13 +34,13 @@ #include } -#include +#include #include "utils.h" #include "neth.h" #include "game.h" - +GameP g_game; class TurnStarter: public ITurnStarter { public: @@ -68,6 +69,7 @@ Utils::seed_random(); GameP game = new Game(&argc,argv); + g_game = game; // assert (clock() != -1); --- xevil-2.02r2.orig/x11/viewport.h +++ xevil-2.02r2/x11/viewport.h @@ -348,7 +348,7 @@ /* NOTE: Will draw everything if redrawArena is true, else just what has changed. */ - void draw_string(const Pos &pos,char *msg); + void draw_string(const Pos &pos,const char *msg); /* EFFECTS: Draw string msg using current GC on arena with upper left of character at position pos. */ --- xevil-2.02r2.orig/cmn/xetp.h +++ xevil-2.02r2/cmn/xetp.h @@ -83,9 +83,9 @@ static void send_rooms_known(OutStreamP,const Rooms &, int worldVersion,Boolean *map); - static void send_message(OutStreamP,char *msg); + static void send_message(OutStreamP,const char *msg); - static void send_arena_message(OutStreamP,int timeMS,char *msg); + static void send_arena_message(OutStreamP,int timeMS,const char *msg); static void send_command(OutStreamP,const IntelId &,ITcommand); --- xevil-2.02r2.orig/cmn/actual.cpp +++ xevil-2.02r2/cmn/actual.cpp @@ -32,7 +32,7 @@ // Include Files #if X11 -#include +#include #endif #if WIN32 #include @@ -122,6 +122,7 @@ #include "bitmaps/yeti/yeti.bitmaps" +using namespace std; ///// Some helper macros to define creatures with certain abilities. #define DEFINE_CREATURE_CTORS_2(CLASSNAME,ABILITY0,ability0,ABILITY1,ability1) \ @@ -454,9 +455,9 @@ } } - ostrstream msg; - msg << "Explosion hits " << hit << " objects." << ends; - locator->message_enq(msg.str()); + stringstream msg; + msg << "Explosion hits " << hit << " objects."; + locator->message_enq(Utils::strdup(msg.str().c_str())); kill_self(); Physical::act(); @@ -1001,7 +1002,7 @@ if (other && (other->get_class_id() != A_AltarOfSin) && (intel = other->get_intel())) { LocatorP locator = get_locator(); - ostrstream str; + stringstream str; // Turned into a frog/baby seal. if (Utils::coin_flip() && other->is_moving() && @@ -1014,8 +1015,8 @@ str << intel->get_name() << " attacks the Altar of Sin and is " << "turned into a " << (doFrog ? "frog" : "baby-seal") - << "." << ends; - locator->message_enq(str.str()); + << "."; + locator->message_enq(Utils::strdup(str.str().c_str())); other->set_intel(NULL); if (!other->get_mapped()) { @@ -1047,8 +1048,8 @@ // Lose all health. else { str << "BLASPHMER! " << intel->get_name() << - " loses health for daring to attack the Altar of Sin." << ends; - locator->message_enq(str.str()); + " loses health for daring to attack the Altar of Sin."; + locator->message_enq(Utils::strdup(str.str().c_str())); int damage = other->get_health(); other->corporeal_attack(this,damage); @@ -1075,8 +1076,8 @@ (intel = other->get_intel()) && intel->is_human()) { int lives = intel->get_lives(); LocatorP locator = get_locator(); - ostrstream msg; - ostrstream arenaMsg; + stringstream msg; + stringstream arenaMsg; // Choose different blessings to give. int n = 0; @@ -1112,8 +1113,8 @@ } else { intel->set_lives(lives + 1); - msg << intel->get_name() << " sells soul for an extra life." << ends; - arenaMsg << "You Sold Your Soul For an Extra Life" << ends; + msg << intel->get_name() << " sells soul for an extra life."; + arenaMsg << "You Sold Your Soul For an Extra Life"; } break; @@ -1123,8 +1124,8 @@ mod = new DoubleSpeed(); assert(mod); modList->append_unique(mod); - msg << intel->get_name() << " sells soul for Double Speed." << ends; - arenaMsg << "Double Speed" << ends; + msg << intel->get_name() << " sells soul for Double Speed."; + arenaMsg << "Double Speed"; break; @@ -1138,9 +1139,8 @@ mod = new DoubleJump(); assert(mod); modList->append_unique(mod); - msg << intel->get_name() << " sells soul for extra jumping powers." - << ends; - arenaMsg << "Extra Jumping Powers" << ends; + msg << intel->get_name() << " sells soul for extra jumping powers."; + arenaMsg << "Extra Jumping Powers"; break; @@ -1157,8 +1157,8 @@ // So max health takes effect immediately. other->heal(); - msg << intel->get_name() << " sells soul for Double Health." << ends; - arenaMsg << "Double Health" << ends; + msg << intel->get_name() << " sells soul for Double Health."; + arenaMsg << "Double Health"; break; @@ -1176,8 +1176,8 @@ // Might as well make sure they can take advantage of it now. other->heal(); - msg << intel->get_name() << " sells soul for Healing Powers." << ends; - arenaMsg << "Healing Powers" << ends; + msg << intel->get_name() << " sells soul for Healing Powers."; + arenaMsg << "Healing Powers"; } break; @@ -1193,8 +1193,8 @@ // Already checked that other is a Creature(). ((CreatureP)other)->add_ability(a); - msg << intel->get_name() << " sells soul for HellFire Powers." << ends; - arenaMsg << "HellFire Powers" << ends; + msg << intel->get_name() << " sells soul for HellFire Powers."; + arenaMsg << "HellFire Powers"; } break; @@ -1217,8 +1217,8 @@ // Already checked that other is a Creature(). ((CreatureP)other)->add_ability(a); - msg << intel->get_name() << " sells soul for Fireballs." << ends; - arenaMsg << "Fireballs" << ends; + msg << intel->get_name() << " sells soul for Fireballs."; + arenaMsg << "Fireballs"; } break; @@ -1241,8 +1241,8 @@ // Already checked that other is a Creature(). ((CreatureP)other)->add_ability(a); - msg << intel->get_name() << " sells soul for Flying Powers." << ends; - arenaMsg << "Flying Powers" << ends; + msg << intel->get_name() << " sells soul for Flying Powers."; + arenaMsg << "Flying Powers"; } break; @@ -1274,8 +1274,8 @@ // Already checked that other is a Creature(). ((CreatureP)other)->add_ability(a); - msg << intel->get_name() << " sells soul for Sticky Powers." << ends; - arenaMsg << "Sticky Powers" << ends; + msg << intel->get_name() << " sells soul for Sticky Powers."; + arenaMsg << "Sticky Powers"; } break; @@ -1285,8 +1285,8 @@ } } // while - locator->message_enq(msg.str()); - locator->arena_message_enq(arenaMsg.str(),other); + locator->message_enq(Utils::strdup(msg.str().c_str())); + locator->arena_message_enq(Utils::strdup(arenaMsg.str().c_str()),other); kill_self(); turnTaken = True; @@ -1534,7 +1534,7 @@ void *closure) { // notThis is used to prevent transmogifying into the same class an object // already is. - ClassId notThis = (ClassId)closure; + ClassId notThis = (long)closure; if (pc->classId == notThis) { return False; } @@ -2087,10 +2087,9 @@ PhysicalP seal = new Seal(w,l,pos); assert(seal); - char sealStr[20]; - ostrstream str(sealStr,20); - str << "seal-" << sealsNum << ends; - NeutralP sealIntel = new SealIntel(w,l,sealStr,homeId); + stringstream str; + str << "seal-" << sealsNum; + NeutralP sealIntel = new SealIntel(w,l,Utils::strdup(str.str().c_str()),homeId); seal->set_intel(sealIntel); l->register_neutral(sealIntel); seals[sealsNum] = sealIntel->get_intel_id(); --- xevil-2.02r2.orig/cmn/xetp.cpp +++ xevil-2.02r2/cmn/xetp.cpp @@ -29,9 +29,9 @@ #include "stdafx.h" -#include +#include #if X11 -#include +#include #endif #if WIN32 #include @@ -53,6 +53,8 @@ #include "xetp.h" +using namespace std; + void XETP::check_sizes() { XETPBasic::check_sizes(); @@ -159,7 +161,7 @@ for (n = 0; n < physicals.length(); n++) { PhysicalP p = (PhysicalP)physicals.get(n); // computing object_length twice, but who cares. - _send_object(out,p,turn,(TickType)tickTypes.get(n), + _send_object(out,p,turn,(long)tickTypes.get(n), compute_object_length(p)); } @@ -274,7 +276,7 @@ -void XETP::send_message(OutStreamP out,char *msg) { +void XETP::send_message(OutStreamP out,const char *msg) { assert(msg); u_int len = strlen(msg); @@ -293,7 +295,7 @@ -void XETP::send_arena_message(OutStreamP out,int time,char *msg) { +void XETP::send_arena_message(OutStreamP out,int time,const char *msg) { assert(msg); u_int len = sizeof(int) + // time strlen(msg); // string body --- xevil-2.02r2.orig/cmn/game.h +++ xevil-2.02r2/cmn/game.h @@ -35,7 +35,7 @@ extern "C" { #include } -#include +#include #include "utils.h" #include "ui.h" #include "world.h" @@ -268,8 +268,8 @@ private: enum { - WITTY_SAYINGS_NUM = 147, - INTEL_NAMES_NUM = 74, + WITTY_SAYINGS_NUM = 155, + INTEL_NAMES_NUM = 77, RANKING_SETS_NUM = 12, }; --- xevil-2.02r2.orig/cmn/area.cpp +++ xevil-2.02r2/cmn/area.cpp @@ -34,12 +34,13 @@ extern "C" { #include // For INT_MAX } -#include +#include #include "utils.h" #include "coord.h" #include "area.h" +using namespace std; Size Area::operator - (const Area &other) const { assert ((shape == AR_RECT) && (other.shape == AR_RECT)); --- xevil-2.02r2.orig/cmn/streams.cpp +++ xevil-2.02r2/cmn/streams.cpp @@ -31,12 +31,13 @@ #include "utils.h" #include "neth.h" // needed for recv, send, recvfrom, sendto -#include +#include #include "streams.h" #include "xetp.h" // yuck, need this for XETP::versionStr +using namespace std; Checksum GenericStream::compute_checksum(u_char *data,int len) { Checksum c = 0; @@ -205,7 +206,7 @@ -Boolean NetOutStream::write(void *buf,int size) { +Boolean NetOutStream::write(const void *buf,int size) { if (!isAlive) { return False; } @@ -518,7 +519,7 @@ -Boolean UDPOutStream::write(void *buf,int size) { +Boolean UDPOutStream::write(const void *buf,int size) { if (!isAlive) { return False; } --- xevil-2.02r2.orig/cmn/streams.h +++ xevil-2.02r2/cmn/streams.h @@ -97,7 +97,7 @@ public: OutStream(Boolean ownSock) : GenericStream(ownSock) {} - virtual Boolean write(void *buf,int size) = 0; + virtual Boolean write(const void *buf,int size) = 0; /* EFFECTS: Write size number of bytes into buf. Return True if successful. */ @@ -171,7 +171,7 @@ virtual Boolean alive(); - virtual Boolean write(void *buf,int size); + virtual Boolean write(const void *buf,int size); virtual void write_char(u_char); @@ -253,7 +253,7 @@ virtual void done_packet(); - virtual Boolean write(void *buf,int size); + virtual Boolean write(const void *buf,int size); void flush(); --- xevil-2.02r2.orig/cmn/utils.cpp +++ xevil-2.02r2/cmn/utils.cpp @@ -30,16 +30,16 @@ // Include Files #include "stdafx.h" -#include +#include #include #include #include -#include +#include #if WIN32 #include #endif #if X11 -#include +#include #endif #ifdef WIN32 @@ -422,10 +422,8 @@ char* Utils::get_OS_info() { - ostrstream ret; - - #ifdef WIN32 + stringstream ret; OSVERSIONINFO osInfo; osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); Boolean set = False; @@ -465,12 +463,11 @@ Utils::strcmp(osInfo.szCSDVersion," ")) { ret << '(' << osInfo.szCSDVersion << ')'; } - ret << ends; } } if (!set) { - ret << "Unknown Win32" << ends; + ret << "Unknown Win32"; } #endif @@ -494,20 +491,15 @@ if (buffer[strLen - 1] == '\n') { buffer[strLen - 1] = '\0'; } - ret << buffer << ends; - set = True; + return strdup(buffer); } } pclose(fp); } - if (!set) { - ret << "Unknown UNIX" << ends; - } + return strdup("Unknown UNIX"); #endif - - return ret.str(); } @@ -605,7 +597,7 @@ // Not tested. out->write_int(len); for (int n = 0; n < len; n++) { - out->write_int((int)data[n]); + out->write_int((long)data[n]); } } @@ -761,7 +753,7 @@ private: - Bucket* HashTable::_get(int &index,void* key); + Bucket* _get(int &index,void* key); /* MODIFIES: index */ /* EFFECTS: Internal helper function. Return the Bucket containing key or NULL if not found. Set index to the bucket list for key whether @@ -944,7 +936,7 @@ // Pretty crappy hash function, I know. // Careful if bucketsNum is a power of 2. int HashTable::defaultHash(void* key,int bucketsNum) { - return ((unsigned int)key) % bucketsNum; + return ((unsigned long)key) % bucketsNum; } @@ -1024,7 +1016,7 @@ #endif #if X11 - cout << str << endl; + std::cout << str << std::endl; #endif } --- xevil-2.02r2.orig/cmn/physical.cpp +++ xevil-2.02r2/cmn/physical.cpp @@ -33,10 +33,10 @@ // Include Files #include "xdata.h" #include "physical.h" -#include +#include #if X11 -#include +#include #endif #if WIN32 #include @@ -54,6 +54,7 @@ #include "bitmaps/transform/transform.bitmaps" +using namespace std; // Defines #define VEL_SMALL 1 @@ -523,9 +524,9 @@ if (heat == 0 && heatNext > 0) { LocatorP l = get_locator(); - ostrstream str; - str << get_class_name() << " is on fire." << ends; - locator->message_enq(str.str()); + stringstream str; + str << get_class_name() << " is on fire."; + locator->message_enq(Utils::strdup(str.str().c_str())); } } previousHeatWasSecondary = secondary; @@ -1844,7 +1845,7 @@ } // Use the pixmap resource id as the base. - u_int cmnBitsId = (unsigned int)mc->pixmapBits[baseDir][animNum]; + u_int cmnBitsId = (unsigned long)mc->pixmapBits[baseDir][animNum]; // It is ok to call OneTransform::compute_key() even if there is no // transformation, will just return 0x0. @@ -2556,17 +2557,17 @@ void Item::die() { LocatorP locator = get_locator(); - ostrstream msg; + stringstream msg; switch (dieMessage) { case NONE: break; case USED: - msg << get_class_name() << " has been used." << ends; - locator->message_enq(msg.str()); + msg << get_class_name() << " has been used."; + locator->message_enq(Utils::strdup(msg.str().c_str())); break; case DESTROYED: - msg << get_class_name() << " is destroyed." << ends; - locator->message_enq(msg.str()); + msg << get_class_name() << " is destroyed."; + locator->message_enq(Utils::strdup(msg.str().c_str())); break; }; @@ -2650,10 +2651,8 @@ // Prevent non-biologicals from picking up drugs. if (p->is_creature() && !((CreatureP)p)->biological()) { - ostrstream msg; - msg << "Non-Biological Creatures Cannot Use Drugs" << ends; LocatorP locator = get_locator(); - locator->arena_message_enq(msg.str(),p); + locator->arena_message_enq(Utils::strdup("Non-Biological Creatures Cannot Use Drugs"), p); kill_self(); } else { @@ -2673,13 +2672,11 @@ assert(context->odChance >= 0); if (context->odChance && Utils::choose(context->odChance) == 0) { p->kill_self(); - ostrstream msg; - msg << p->get_class_name() << " dies from crack overdose." << ends; - locator->message_enq(msg.str()); + stringstream msg; + msg << p->get_class_name() << " dies from crack overdose."; + locator->message_enq(Utils::strdup(msg.str().c_str())); - ostrstream arenaMsg; - arenaMsg << "You Died From Drug Overdose" << ends; - locator->arena_message_enq(arenaMsg.str(),p); + locator->arena_message_enq(Utils::strdup("You Died From Drug Overdose"),p); set_quiet_death(); // so doesn't report "has been used" message. } @@ -2693,9 +2690,7 @@ } else { // Shouldn't get here, should kill self when picking it up. - ostrstream msg; - msg << "Non-Biological Creatures Cannot Use Drugs" << ends; - locator->arena_message_enq(msg.str(),p); + locator->arena_message_enq(Utils::strdup("Non-Biological Creatures Cannot Use Drugs"),p); } kill_self(); @@ -4334,14 +4329,14 @@ if (!get_quiet_death() && !alive() && (corpseTimer.ready() || (get_health() < - cc->corpseHealth))) { LocatorP locator = get_locator(); - ostrstream msg; + stringstream msg; if (corpseTimer.ready()) { - msg << get_class_name() << " corpse has decomposed." << ends; - locator->message_enq(msg.str()); + msg << get_class_name() << " corpse has decomposed."; + locator->message_enq(Utils::strdup(msg.str().c_str())); } else { - msg << get_class_name() << " corpse has been destroyed." << ends; - locator->message_enq(msg.str()); + msg << get_class_name() << " corpse has been destroyed."; + locator->message_enq(Utils::strdup(msg.str().c_str())); } set_delete_me(); } @@ -4399,9 +4394,9 @@ set_vel_next(velNew); set_stance_next(CO_air); - ostrstream msg; - msg << get_class_name() << " has died." << ends; - locator->message_enq(msg.str()); + stringstream msg; + msg << get_class_name() << " has died."; + locator->message_enq(Utils::strdup(msg.str().c_str())); set_no_death_delete(); } @@ -6072,10 +6067,10 @@ } // If User is already holding the max number of weapons. else if (weaponsNum >= PH_WEAPONS_MAX) { - ostrstream msg; - msg << "Can only hold " << PH_WEAPONS_MAX << " weapons" << ends; + stringstream msg; + msg << "Can only hold " << PH_WEAPONS_MAX << " weapons"; LocatorP locator = cre->get_locator(); - locator->arena_message_enq(msg.str(),cre); + locator->arena_message_enq(Utils::strdup(msg.str().c_str()),cre); destroyOther = True; } // Actually pick it up. @@ -6124,15 +6119,14 @@ else { LocatorP locator = cre->get_locator(); if (itemsNum == PH_ITEMS_MAX) { - ostrstream msg; - msg << "Can only hold " << PH_ITEMS_MAX << " items" << ends; - locator->arena_message_enq(msg.str(),cre); + stringstream msg; + msg << "Can only hold " << PH_ITEMS_MAX << " items"; + locator->arena_message_enq(Utils::strdup(msg.str().c_str()),cre); } else if (itemClassCount >= ITEM_CLASS_MAX) { - ostrstream msg; - msg << "Can only hold " << ITEM_CLASS_MAX - << " of any one item" << ends; - locator->arena_message_enq(msg.str(),cre); + stringstream msg; + msg << "Can only hold " << ITEM_CLASS_MAX << " of any one item"; + locator->arena_message_enq(Utils::strdup(msg.str().c_str()),cre); } other->set_quiet_death(); @@ -6661,9 +6655,9 @@ ((ItemP)p)->use(cre); } else { - ostrstream str; - str << "Cannot use " << p->get_class_name() << ends; - locator->arena_message_enq(str.str(),cre); + stringstream str; + str << "Cannot use " << p->get_class_name(); + locator->arena_message_enq(Utils::strdup(str.str().c_str()),cre); } } break; --- xevil-2.02r2.orig/cmn/role.h +++ xevil-2.02r2/cmn/role.h @@ -539,7 +539,7 @@ public: - Server(Boolean localHuman,char *portName,LocatorP); + Server(Boolean localHuman,const char *portName,LocatorP); /* EFFECTS: Create a server that listens for connections on given port. If NULL is passed in, use XETP::DEFAULT_PORT. */ --- xevil-2.02r2.orig/cmn/intel.cpp +++ xevil-2.02r2/cmn/intel.cpp @@ -35,7 +35,7 @@ #include } #if X11 -#include +#include #endif #if WIN32 #include @@ -50,6 +50,7 @@ #include "xdata.h" +using namespace std; // Defines #define FIGHT_RANGE 40 // made it smaller for Dogs 45 // [50-40] @@ -212,7 +213,7 @@ -Intel::Intel(WorldP w,LocatorP l,char *name, +Intel::Intel(WorldP w,LocatorP l,const char *name, const IntelOptions *ops,ITmask opMask) { intelStatusChanged = True; living = True; @@ -755,7 +756,7 @@ -Human::Human(WorldP w,LocatorP l,char *name,int lves, +Human::Human(WorldP w,LocatorP l,const char *name,int lves, int *sharedLves,ColorNum cNum) : Intel(w,l,name,NULL,ITnone) { lives = lves; @@ -931,7 +932,7 @@ -Machine::Machine(WorldP w,LocatorP l,char *name,const IntelOptions *ops, +Machine::Machine(WorldP w,LocatorP l,const char *name,const IntelOptions *ops, ITmask opMask) : Intel(w,l,name,ops,opMask) { @@ -1829,7 +1830,7 @@ -Enemy::Enemy(WorldP w,LocatorP l,char *name, +Enemy::Enemy(WorldP w,LocatorP l,const char *name, const IntelOptions *ops,ITmask opMask) :Machine(w,l,name,ops,opMask) {} @@ -1854,7 +1855,7 @@ -Neutral::Neutral(WorldP w,LocatorP l,char *name, +Neutral::Neutral(WorldP w,LocatorP l,const char *name, const IntelOptions *ops,ITmask opMask) :Machine(w,l,name,ops,opMask) {} @@ -1867,7 +1868,7 @@ -SealIntel::SealIntel(WorldP w,LocatorP l,char *name,const Id &home_id) +SealIntel::SealIntel(WorldP w,LocatorP l,const char *name,const Id &home_id) :Neutral(w,l,name,NULL,ITnone) { // Timer oTimer(LADDER_JUMP_TIME); @@ -1906,7 +1907,7 @@ -DoppelIntel::DoppelIntel(WorldP w,LocatorP l,char *name, +DoppelIntel::DoppelIntel(WorldP w,LocatorP l,const char *name, const IntelOptions *ops,ITmask opMask,IntelP master) :Neutral(w,l,name,ops,opMask) { assert(master); @@ -2073,7 +2074,7 @@ -Pet::Pet(WorldP w,LocatorP l,char *name, +Pet::Pet(WorldP w,LocatorP l,const char *name, const IntelOptions *ops,ITmask opMask,IntelP master) :DoppelIntel(w,l,name,ops,opMask,master) { mode = Heel; @@ -2095,7 +2096,7 @@ char buffer[80]; ostrstream str(buffer,80); str << "mode changing from:" << Pet::mode_string(prev) << - " to: " << Pet::mode_string(curr) << endl << ends; + " to: " << Pet::mode_string(curr) << endl; #if WIN32 TRACE(buffer); #endif --- xevil-2.02r2.orig/cmn/utils.h +++ xevil-2.02r2/cmn/utils.h @@ -159,7 +159,7 @@ typedef int GameStyleType; // Possible values of GameStyleType. -enum {SCENARIOS,LEVELS_ONLY,KILL,DUEL,EXTENDED,TRAINING,LEVELS}; +enum {SCENARIOS,LEVELS_ONLY,KILL,DUEL,EXTENDED,TRAINING,LEVELS,NUM_GAME_STYLES}; --- xevil-2.02r2.orig/cmn/locator.cpp +++ xevil-2.02r2/cmn/locator.cpp @@ -50,6 +50,7 @@ #include "bitmaps/locator/locator.bitmaps" // for arrows +using namespace std; // When we reach this, start deleting objects. #define OL_LIST_WARN ((int)(OL_LIST_MAX * 0.9)) --- xevil-2.02r2.orig/cmn/role.cpp +++ xevil-2.02r2/cmn/role.cpp @@ -29,9 +29,9 @@ #include "stdafx.h" -#include +#include #if X11 -#include +#include #include #endif #if WIN32 @@ -266,43 +266,39 @@ void Role::error(const char *msg1,const char *msg2,const char *msg3) { - ostrstream str; + stringstream str; if (msg2 == NULL) { - str << msg1 << ends; + str << msg1; } else if (msg3 == NULL) { - str << msg1 << msg2 << ends; + str << msg1 << msg2; } else { - str << msg1 << msg2 << msg3 << ends; + str << msg1 << msg2 << msg3; } // Call one argument version. - _error(str.str()); - - delete str.str(); + _error(str.str().c_str()); } void Role::message(const char *msg1,const char *msg2,const char *msg3) { - ostrstream str; + stringstream str; if (msg2 == NULL) { - str << msg1 << ends; + str << msg1; } else if (msg3 == NULL) { - str << msg1 << msg2 << ends; + str << msg1 << msg2; } else { - str << msg1 << msg2 << msg3 << ends; + str << msg1 << msg2 << msg3; } // Call one argument version. - _message(str.str()); - - delete str.str(); + _message(str.str().c_str()); } @@ -605,11 +601,11 @@ // Display message that we are looking up IP address. // Assumes that caller will call Client::connect_server after a turn or two, // so the message will be displayed on the Ui. - ostrstream str; - str << "Looking up IP address for server " << serverName << ends; + stringstream str; + str << "Looking up IP address for server " << serverName; // Display for a long time. - errLocator->arena_message_enq(str.str(),NULL,1000000); - errLocator->message_enq(Utils::strdup(str.str())); + errLocator->arena_message_enq(Utils::strdup(str.str().c_str()),NULL,1000000); + errLocator->message_enq(Utils::strdup(str.str().c_str())); // Probably would be better to use Role::message(), but we want it to stay // up for a long time. Should add argument to Role::message(). @@ -663,12 +659,10 @@ } } if (n == CLIENT_PORT_TRIES) { - ostrstream str; + stringstream str; str << "Could not bind local UDP port to any of " - << clientPortBase << "-" << (clientPortBase + CLIENT_PORT_TRIES - 1) - << ends; - error(str.str()); - delete str.str(); + << clientPortBase << "-" << (clientPortBase + CLIENT_PORT_TRIES - 1); + error(str.str().c_str()); return; } // cout << "UDP port seems to be" << client.sin_port << endl; @@ -703,22 +697,19 @@ // Inform user of failed connection if (!ok()) { - strstream msg; + stringstream msg; msg << "Could not connect to " << serverName << " on port " << - port << "." << ends; - error(msg.str()); - delete(msg.str()); + port << "."; + error(msg.str().c_str()); delete tcpOut; return; } // Inform user of successful connection - strstream msg; + stringstream msg; msg << hostName << " connected to " << serverName << " on port " << - port << ends; - message(msg.str()); - delete msg.str(); - + port; + message(msg.str().c_str()); // Create TCP and UDP streams. tcpIn = new NetInStream(tcpSock,False); @@ -967,11 +958,11 @@ Role::_error(msg); if (errorLocator) { - ostrstream str2; - str2 << "ERROR: " << msg << ends; - errorLocator->arena_message_enq(str2.str(),NULL,ROLE_FAILED_TIME); + stringstream str2; + str2 << "ERROR: " << msg; + errorLocator->arena_message_enq(Utils::strdup(str2.str().c_str()),NULL,ROLE_FAILED_TIME); // Don't delete str2.str(), give memory to the Locator. - errorLocator->message_enq(Utils::strdup(str2.str())); + errorLocator->message_enq(Utils::strdup(str2.str().c_str())); } #if WIN32 // Only the client can afford to block on error messages. @@ -986,11 +977,9 @@ Role::_error(msg); if (errorLocator) { - ostrstream str2; - str2 << msg << ends; - errorLocator->arena_message_enq(str2.str()); + errorLocator->arena_message_enq(Utils::strdup(msg)); // Don't delete str2.str(), give memory to the Locator. - errorLocator->message_enq(Utils::strdup(str2.str())); + errorLocator->message_enq(Utils::strdup(msg)); } } @@ -1256,10 +1245,9 @@ if (turn > turnMax) { turnMax = turn; if (echoPingPong) { - ostrstream str; - str << "PONG the server with turn " << turnMax << ends; - message(str.str()); - delete str.str(); + stringstream str; + str << "PONG the server with turn " << turnMax; + message(str.str().c_str()); } // Tell server so it can free turn windows to send more data. XETP::send_pong(udpOut,turnMax); @@ -1365,10 +1353,9 @@ } } else { - ostrstream str; - str << "No context for classId " << classId << ends; - error(str.str()); - delete str.str(); + stringstream str; + str << "No context for classId " << classId; + error(str.str().c_str()); } } } @@ -1582,9 +1569,9 @@ return Utils::strdup(clientName); } - ostrstream str; - str << '\"' << intel->get_name() << "\"@" << clientName << ends; - return str.str(); + stringstream str; + str << '\"' << intel->get_name() << "\"@" << clientName; + return Utils::strdup(str.str().c_str()); } @@ -1695,11 +1682,10 @@ } #ifdef SKIP_MESSAGES - ostrstream msg; + stringstream msg; msg << "Average delay is " << avg << " out of " - << delaysNum << " samples." << ends; + << delaysNum << " samples."; server->message(msg.str()); - delete msg.str(); #endif #if 0 @@ -1723,10 +1709,9 @@ // server->error("Client has reached maximum skip value."); // } #ifdef SKIP_MESSAGES - ostrstream msg; - msg << "Increasing skip to " << skip << ends; + stringstream msg; + msg << "Increasing skip to " << skip; server->message(msg.str()); - delete msg.str(); #endif } // We have moved back into our target range, can send more data now. @@ -1734,10 +1719,9 @@ skip--; #ifdef SKIP_MESSAGES - ostrstream msg; - msg << "Decreasing skip to " << skip << ends; + stringstream msg; + msg << "Decreasing skip to " << skip; server->message(msg.str()); - delete msg.str(); #endif } @@ -1777,7 +1761,7 @@ -Server::Server(Boolean lHuman,char *portName,LocatorP errLocator) { +Server::Server(Boolean lHuman,const char *portName,LocatorP errLocator) { // Hack, using errLocator for more than reporting errors. errLocator->set_remember_deleted(True); errLocator->set_remember_sounds(True); @@ -1843,19 +1827,17 @@ // Give address to both the TCP and UDP sockets. if (bind(tcpSock, (CMN_SOCKADDR *)&serverAddr, sizeof(serverAddr)) < 0) { - ostrstream str; + stringstream str; str << "Couldn't bind socket name to TCP socket on port " - << port << "." << ends; - error(str.str()); - delete str.str(); + << port << "."; + error(str.str().c_str()); return; } if (bind(udpSock, (CMN_SOCKADDR *)&serverAddr, sizeof(serverAddr)) < 0) { - ostrstream str; + stringstream str; str << "Couldn't bind socket name to UDP socket on port " - << port << "." << ends; - error(str.str()); - delete str.str(); + << port << "."; + error(str.str().c_str()); return; } @@ -1868,10 +1850,9 @@ assert(udpIn); // Message to server log. - strstream msg; - msg << "Set up server on port " << port << ends; - message(msg.str()); - delete(msg.str()); + stringstream msg; + msg << "Set up server on port " << port; + message(msg.str().c_str()); running = True; } @@ -1951,10 +1932,9 @@ localHumanId = hId; // Log the human's name. - strstream msg; - msg << "Player 0 \"" << human->get_name() << '\"' << "@SERVER" << ends; - message(msg.str()); - delete(msg.str()); + stringstream msg; + msg << "Player 0 \"" << human->get_name() << '\"' << "@SERVER"; + message(msg.str().c_str()); return; } @@ -1985,12 +1965,11 @@ // Log all the players in the game, some code duplication for the // local human. - ostrstream str; + stringstream str; char* fullName = cn->get_full_client_name(); - str << "Player " << num << " " << fullName << ends; - message(str.str()); + str << "Player " << num << " " << fullName; + message(str.str().c_str()); delete fullName; - delete str.str(); // Send assign_intel via TCP OutStreamP out = cn->get_tcp_out_stream(); @@ -2007,13 +1986,12 @@ // anyway. for (m = 0; m < connections.length() && m != n; m++) { char* fullName = cn->get_full_client_name(); - ostrstream str; - str << fullName << " has joined the game" << ends; + stringstream str; + str << fullName << " has joined the game"; delete fullName; OutStreamP out = cn->get_udp_out_stream(); - XETP::send_arena_message(out,timeMS,str.str()); - delete str.str(); + XETP::send_arena_message(out,timeMS,str.str().c_str()); } cn->creation_message_sent(); } @@ -2101,13 +2079,12 @@ // Give the connection some slack when it is first starting up. turn - cn->get_start_turn() >= MINIMUM_CUTOFF) { char* fullName = cn->get_full_client_name(); - ostrstream str; + stringstream str; str << fullName << " has not responded in " - << diff << " turns. Disconnect." << ends; - message(str.str()); + << diff << " turns. Disconnect."; + message(str.str().c_str()); delete fullName; - delete str.str(); tooOld = True; } } @@ -2147,11 +2124,10 @@ diff == NO_ACTIVITY_WARN_2 || diff == NO_ACTIVITY_WARN_3) { if (echoPingPong) { - ostrstream str; + stringstream str; str << "Haven't heard from " << cn->get_client_name() - << " in " << diff << " turns, sending PING." << ends; - message(str.str()); - delete str.str(); + << " in " << diff << " turns, sending PING."; + message(str.str().c_str()); } XETP::send_ping(cn->get_udp_out_stream()); } @@ -2311,7 +2287,11 @@ for (m = 0; m < followers.length(); m++) { PhysicalP q = (PhysicalP)followers.get(m); netData = q->get_net_data(); - assert(!netData->get_sent_flag()); + // This line was aborting network games, often in the pound scenario. + // Without it, the server seems to continue without error. + // I tried replacing it with a warning, but there is so much of it + // that it is nearly impossible to see anything else. -Brandon +// assert(!netData->get_sent_flag()); netData->set_sent_flag(True); } @@ -2713,9 +2693,9 @@ // Careful to set the propagate flag to False so the message doesn't get // sent to the clients. if (errorLocator) { - ostrstream str2; - str2 << "SERVER: " << msg << ends; - errorLocator->arena_message_enq(str2.str(),NULL,ROLE_FAILED_TIME,False); + stringstream str2; + str2 << "SERVER: " << msg; + errorLocator->arena_message_enq(Utils::strdup(str2.str().c_str()),NULL,ROLE_FAILED_TIME,False); // Don't delete str2.str(), give memory to the Locator. // Could do a regular message_enq(), but would have to deal with the @@ -2728,10 +2708,9 @@ void Server::display_chat_message(LocatorP l,const char* sender, const char* msg) { // Log the chat message, then let Role handle it. - strstream logMsg; - logMsg << '<' << sender << '>' << msg << ends; - message(logMsg.str()); - delete logMsg.str(); + stringstream logMsg; + logMsg << '<' << sender << '>' << msg; + message(logMsg.str().c_str()); Role::display_chat_message(l,sender,msg); } @@ -2851,12 +2830,11 @@ udpAddr->sin_port = htons(udpPort); // Log the connection. - strstream msg; + stringstream msg; msg << clientName << " connected (TCP port " << ntohs(tcpAddr.sin_port) << - ", UDP port " << udpPort << ")" << ends; - message(msg.str()); - delete(msg.str()); + ", UDP port " << udpPort << ")"; + message(msg.str().c_str()); Connection* cn = new Connection(this,errorLocator, @@ -2874,7 +2852,7 @@ XETP::send_reset(out,manager->get_game_style_type()); // Say hello to the new client. - ostrstream greeting; + stringstream greeting; greeting << "Welcome to " << hostName << "."; if (get_humans_num() == 1) { @@ -2884,10 +2862,8 @@ greeting << " There are now " << get_humans_num() << " players."; } - greeting << ends; int timeMS = quantaToMS(UI_ARENA_MESSAGE_TIME,manager); - XETP::send_arena_message(out,timeMS,greeting.str()); - delete greeting.str(); + XETP::send_arena_message(out,timeMS,greeting.str().c_str()); manager->humans_num_incremented(); } @@ -2918,18 +2894,16 @@ Connection* cm = get_connection(m); char* fullName = cn->get_full_client_name(); - ostrstream str; + stringstream str; str << fullName << " has disconnected"; if (intel) { str << ", " << kills << " human kills"; } - str << ends; XETP::send_arena_message(cm->get_udp_out_stream(), - timeMS,str.str()); + timeMS,str.str().c_str()); delete fullName; - delete str.str(); } } --- xevil-2.02r2.orig/cmn/world.cpp +++ xevil-2.02r2/cmn/world.cpp @@ -35,7 +35,7 @@ #endif // Include Files. -#include +#include #include "utils.h" #include "coord.h" @@ -48,6 +48,7 @@ // For PhysMover. #include "actual.h" +using namespace std; // Defines. #define HANGING_PERCENT 0.40 // The % of the edge hanging off the corner. --- xevil-2.02r2.orig/cmn/intel.h +++ xevil-2.02r2/cmn/intel.h @@ -123,7 +123,7 @@ // Class Definitions. class Intel { public: - Intel(WorldP w,LocatorP l,char *name, + Intel(WorldP w,LocatorP l,const char *name, const IntelOptions *ops,ITmask opMask); /* EFFECTS: Create a new intel with the options specified in opMakse that are in ops. ops will never be referenced if opMask is ITnone. lives now @@ -293,7 +293,7 @@ // Simply buffers input from a user interface. class Human: public Intel { public: - Human(WorldP w,LocatorP l,char *name,int lives, + Human(WorldP w,LocatorP l,const char *name,int lives, int *sharedLives,ColorNum colorNum); /* NOTE: Uses all default options. intelOptions should be meaningless for a human. If "sharedLives" is non-null, ignore "lives" and share the lives. */ @@ -346,7 +346,7 @@ class Machine: public Intel { public: - Machine(WorldP w,LocatorP l,char *name, + Machine(WorldP w,LocatorP l,const char *name, const IntelOptions *ops,ITmask opMask); virtual IntelId get_master_intel_id(); @@ -464,7 +464,7 @@ class Enemy: public Machine { public: - Enemy(WorldP w,LocatorP l,char *name, + Enemy(WorldP w,LocatorP l,const char *name, const IntelOptions *ops,ITmask opMask); static void set_reflexes_time(int time) {reflexesTime = time;} @@ -491,7 +491,7 @@ class Neutral: public Machine { public: - Neutral(WorldP w,LocatorP l,char *name, + Neutral(WorldP w,LocatorP l,const char *name, const IntelOptions *ops,ITmask opMask); virtual Boolean is_enemy(); @@ -502,7 +502,7 @@ class SealIntel: public Neutral { public: - SealIntel(WorldP w,LocatorP l,char *name,const Id &homeId); + SealIntel(WorldP w,LocatorP l,const char *name,const Id &homeId); virtual Boolean is_seal_intel(); @@ -522,7 +522,7 @@ class DoppelIntel: public Neutral { public: - DoppelIntel(WorldP w,LocatorP l,char *name, + DoppelIntel(WorldP w,LocatorP l,const char *name, const IntelOptions *ops,ITmask opMask, IntelP master = NULL); @@ -572,7 +572,7 @@ // in choose_strategy() and go_get_em(). class Pet: public DoppelIntel { public: - Pet(WorldP w,LocatorP l,char *name, + Pet(WorldP w,LocatorP l,const char *name, const IntelOptions *ops,ITmask opMask, IntelP master = NULL); --- xevil-2.02r2.orig/cmn/locator.h +++ xevil-2.02r2/cmn/locator.h @@ -47,7 +47,7 @@ // Include Files -#include +#include #include "utils.h" #include "coord.h" @@ -96,6 +96,8 @@ #define OL_RECENT_SOUNDS_MAX 30 +class OLgridEntry; +class OLshadowEntry; // An entry for one object in the list of all objects currently in the game. class OLentry { --- xevil-2.02r2.orig/cmn/physical.h +++ xevil-2.02r2/cmn/physical.h @@ -93,7 +93,7 @@ CLASSNAME::CLASSNAME(InStreamP in,const CLASSNAME ## Context &cx, \ CLASSNAME ## Xdata &x_data, \ WorldP w,LocatorP l) \ - : PARENT(in,cx. ## parent ## Context,x_data,w,l) + : PARENT(in,cx. parent ## Context,x_data,w,l) // Used by internal nodes and leaves. #define DEFINE_UPDATE_FROM_STREAM(CLASSNAME,PARENT) \ --- xevil-2.02r2.orig/cmn/game_style.h +++ xevil-2.02r2/cmn/game_style.h @@ -30,12 +30,7 @@ #endif #endif -#if X11 -#include -#endif -#if WIN32 -#include -#endif +#include #include "utils.h" #include "coord.h" @@ -44,6 +39,8 @@ #include "intel.h" +using namespace std; + #define SCENARIO_SEALS_TRAPDOORS 2 #define SCENARIO_BONUS_FROGS 12 #define SCENARIO_FLAG_FLAGS 15 @@ -91,7 +88,7 @@ virtual GameStyle *clone() = 0; - virtual void describe(ostrstream &) = 0; + virtual void describe(stringstream &) = 0; /* EFFECTS: Write a two-line description of the style to the stream. */ virtual GameStyleType get_type() = 0; @@ -137,7 +134,7 @@ virtual int new_level_check(int enemiesPlaying,WorldP,LocatorP, int level, - Boolean &lStrChanged,ostrstream &levelStr, + Boolean &lStrChanged,stringstream &levelStr, Timer &timer, IPhysicalManagerP); /* MODIFIES: lStrChanged */ @@ -166,7 +163,7 @@ virtual void new_level(int level,WorldP,LocatorP, const DifficultyLevel &dLevel, - ostrstream &levelStr,ostrstream &levelTitleStr, + stringstream &levelStr,stringstream &levelTitleStr, IPhysicalManagerP,int humansNum) = 0; /* MODIFIES: level */ /* EFFECTS: Start a new level. Use levelStr levelTitleStr to @@ -249,7 +246,7 @@ virtual GameStyleP clone(); - virtual void describe(ostrstream &); + virtual void describe(stringstream &); virtual GameStyleType get_type(); @@ -269,7 +266,7 @@ virtual int new_level_check(int enemiesPlaying,WorldP,LocatorP, int level,Boolean &lStrChanged, - ostrstream &levelStr,Timer &timer, + stringstream &levelStr,Timer &timer, IPhysicalManagerP); virtual Boolean advance_level(); @@ -277,7 +274,7 @@ virtual Boolean award_bonus(); virtual void new_level(int level,WorldP,LocatorP,const DifficultyLevel &dLevel, - ostrstream &levelStr,ostrstream &levelTitleStr, + stringstream &levelStr,stringstream &levelTitleStr, IPhysicalManagerP,int humansNum); virtual void new_level_set_timer(Timer &timer); @@ -305,7 +302,7 @@ virtual GameStyleP clone(); - virtual void describe(ostrstream &); + virtual void describe(stringstream &); virtual GameStyleType get_type(); @@ -314,11 +311,11 @@ virtual void reset(WorldP,LocatorP,const DifficultyLevel &,int enemiesNumNext); virtual int new_level_check(int enemiesPlaying,WorldP,LocatorP, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &timer, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &timer, IPhysicalManagerP); virtual void new_level(int level,WorldP,LocatorP,const DifficultyLevel &dLevel, - ostrstream &levelStr,ostrstream &levelTitleStr, + stringstream &levelStr,stringstream &levelTitleStr, IPhysicalManagerP,int humansNum); virtual void new_level_set_timer(Timer &timer); @@ -340,7 +337,7 @@ virtual GameStyleP clone(); - virtual void describe(ostrstream &); + virtual void describe(stringstream &); virtual GameStyleType get_type(); @@ -355,7 +352,7 @@ virtual Boolean game_over_check(int humansPlaying,int enemiesPlaying); virtual void new_level(int level,WorldP,LocatorP,const DifficultyLevel &dLevel, - ostrstream &levelStr,ostrstream &levelTitleStr, + stringstream &levelStr,stringstream &levelTitleStr, IPhysicalManagerP,int humansNum); virtual void refill_enemies(Boolean enemiesRefill,WorldP,LocatorP,IPhysicalManagerP); @@ -376,7 +373,7 @@ virtual GameStyleP clone(); - virtual void describe(ostrstream &); + virtual void describe(stringstream &); virtual GameStyleType get_type(); @@ -389,7 +386,7 @@ virtual Boolean game_over_check(int humansPlaying,int enemiesPlaying); virtual void new_level(int level,WorldP,LocatorP,const DifficultyLevel &dLevel, - ostrstream &levelStr,ostrstream &levelTitleStr, + stringstream &levelStr,stringstream &levelTitleStr, IPhysicalManagerP,int humansNum); virtual void refill_enemies(Boolean enemiesRefill,WorldP,LocatorP,IPhysicalManagerP); @@ -408,7 +405,7 @@ virtual GameStyleP clone(); - virtual void describe(ostrstream &); + virtual void describe(stringstream &); virtual GameStyleType get_type(); @@ -423,7 +420,7 @@ virtual Boolean game_over_check(int humansPlaying,int enemiesPlaying); virtual void new_level(int level,WorldP,LocatorP,const DifficultyLevel &dLevel, - ostrstream &levelStr,ostrstream &levelTitleStr, + stringstream &levelStr,stringstream &levelTitleStr, IPhysicalManagerP,int humansNum); virtual void refill_enemies(Boolean enemiesRefill,WorldP,LocatorP,IPhysicalManagerP); @@ -442,7 +439,7 @@ virtual GameStyleP clone(); - virtual void describe(ostrstream &); + virtual void describe(stringstream &); virtual GameStyleType get_type(); @@ -451,7 +448,7 @@ virtual void reset(WorldP,LocatorP,const DifficultyLevel &dLevel,int); virtual void new_level(int level,WorldP,LocatorP,const DifficultyLevel &dLevel, - ostrstream &levelStr,ostrstream &levelTitleStr, + stringstream &levelStr,stringstream &levelTitleStr, IPhysicalManagerP,int humansNum); virtual void refill_enemies(Boolean enemiesRefill,WorldP,LocatorP,IPhysicalManagerP); @@ -466,7 +463,7 @@ virtual GameStyleP clone(); - virtual void describe(ostrstream &); + virtual void describe(stringstream &); virtual GameStyleType get_type(); @@ -485,7 +482,7 @@ virtual void reset(WorldP,LocatorP,const DifficultyLevel &,int enemiesNumNext); virtual int new_level_check(int enemiesPlaying,WorldP,LocatorP, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &timer, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &timer, IPhysicalManagerP); virtual Boolean advance_level(); @@ -493,7 +490,7 @@ virtual Boolean award_bonus(); virtual void new_level(int level,WorldP,LocatorP,const DifficultyLevel &dLevel, - ostrstream &levelStr,ostrstream &levelTitleStr, + stringstream &levelStr,stringstream &levelTitleStr, IPhysicalManagerP manager,int humansNum); virtual void new_level_set_timer(Timer &timer); --- xevil-2.02r2.orig/cmn/game_style.cpp +++ xevil-2.02r2/cmn/game_style.cpp @@ -33,15 +33,9 @@ #include } -#if X11 -#include -#endif - -#if WIN32 -#include -#endif +#include -#include +#include #include "utils.h" #include "coord.h" #include "world.h" @@ -109,13 +103,13 @@ /* DEFAULT: True */ virtual int new_level_check(int enemiesPlaying,WorldP,LocatorP, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &timer, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &timer, IPhysicalManagerP) = 0; virtual void setup_world(WorldP,LocatorP,const DifficultyLevel &) = 0; virtual void new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &dLevel, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int humansNum) = 0; /* EFFECTS: These two functions start a new level in a scenario. setup_world() should just setup the map and size of the world. new_level() is called after world.reset() @@ -158,13 +152,13 @@ virtual ScenarioType get_scenario_type() {return EXTERMINATE;} virtual int new_level_check(int enemiesPlaying,WorldP,LocatorP, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &timer, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &timer, IPhysicalManagerP); virtual void setup_world(WorldP,LocatorP,const DifficultyLevel &); virtual void new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &dLevel, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int humansNum); @@ -183,13 +177,13 @@ virtual Boolean can_refill_game_objects(); virtual int new_level_check(int enemiesPlaying,WorldP,LocatorP, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &timer, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &timer, IPhysicalManagerP); virtual void setup_world(WorldP,LocatorP,const DifficultyLevel &); virtual void new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &dLevel, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int humansNum); virtual void new_level_set_timer(Timer &timer); @@ -209,7 +203,7 @@ virtual ScenarioType get_scenario_type() {return HIVE;} virtual int new_level_check(int enemiesPlaying,WorldP,LocatorP, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &timer, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &timer, IPhysicalManagerP); virtual Boolean award_bonus(); @@ -218,7 +212,7 @@ virtual void setup_world(WorldP,LocatorP,const DifficultyLevel &); virtual void new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &dLevel, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int humansNum); virtual void refill_enemies(Boolean enemiesRefill,WorldP,LocatorP,IPhysicalManagerP); @@ -242,13 +236,13 @@ virtual ScenarioType get_scenario_type() {return CAPTURE_THE_FLAG;} virtual int new_level_check(int enemiesPlaying,WorldP,LocatorP, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &timer, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &timer, IPhysicalManagerP); virtual void setup_world(WorldP,LocatorP,const DifficultyLevel &); virtual void new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &dLevel, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int humansNum); virtual void refill_enemies(Boolean enemiesRefill,WorldP,LocatorP,IPhysicalManagerP); @@ -269,7 +263,7 @@ virtual void setup_world(WorldP,LocatorP,const DifficultyLevel &); virtual void new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &dLevel, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int humansNum); virtual Boolean advance_level(); @@ -292,7 +286,7 @@ virtual Boolean (*get_team())(LocatorP,PhysicalP,PhysicalP) = 0; - virtual void set_level_strings(int level,ostrstream &lStr,ostrstream &lTitleStr) = 0; + virtual void set_level_strings(int level,stringstream &lStr,stringstream &lTitleStr) = 0; /* EFFECTS: Called in new_level() to set the appropriate messages. */ @@ -311,7 +305,7 @@ virtual ScenarioType get_scenario_type() {return SEALS;} virtual int new_level_check(int enemiesPlaying,WorldP,LocatorP, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &timer, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &timer, IPhysicalManagerP); virtual Boolean award_bonus(); @@ -323,7 +317,7 @@ #endif virtual Boolean (*get_team())(LocatorP,PhysicalP,PhysicalP); - virtual void set_level_strings(int level,ostrstream &lStr,ostrstream &lTitleStr); + virtual void set_level_strings(int level,stringstream &lStr,stringstream &lTitleStr); private: @@ -342,7 +336,7 @@ virtual ScenarioType get_scenario_type() {return ANTI_SEALS;} virtual int new_level_check(int enemiesPlaying,WorldP,LocatorP, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &timer, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &timer, IPhysicalManagerP); @@ -351,7 +345,7 @@ #endif virtual Boolean (*get_team())(LocatorP,PhysicalP,PhysicalP); - virtual void set_level_strings(int level,ostrstream &lStr,ostrstream &lTitleStr); + virtual void set_level_strings(int level,stringstream &lStr,stringstream &lTitleStr); private: @@ -369,13 +363,13 @@ virtual SoundName get_midisoundtrack(){return SoundNames::FIRE_SOUNDTRACK;} virtual int new_level_check(int enemiesPlaying,WorldP,LocatorP, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &timer, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &timer, IPhysicalManagerP); virtual void setup_world(WorldP,LocatorP,const DifficultyLevel &); virtual void new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &dLevel, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int humansNum); virtual Boolean award_bonus(); @@ -391,13 +385,13 @@ virtual ScenarioType get_scenario_type() {return KILL_THE_DRAGON;} virtual int new_level_check(int enemiesPlaying,WorldP,LocatorP, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &timer, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &timer, IPhysicalManagerP); virtual void setup_world(WorldP,LocatorP,const DifficultyLevel &); virtual void new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &dLevel, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int humansNum); virtual SoundName get_midisoundtrack(){return SoundNames::FIRE_SOUNDTRACK;} @@ -419,13 +413,13 @@ virtual Pos human_initial_pos(WorldP,LocatorP,const Size &s); virtual int new_level_check(int enemiesPlaying,WorldP,LocatorP, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &timer, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &timer, IPhysicalManagerP); virtual void setup_world(WorldP,LocatorP,const DifficultyLevel &); virtual void new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &dLevel, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int humansNum); virtual void refill_enemies(Boolean enemiesRefill,WorldP,LocatorP,IPhysicalManagerP); @@ -447,13 +441,13 @@ virtual ScenarioType get_scenario_type() {return THE_POUND;} virtual int new_level_check(int enemiesPlaying,WorldP,LocatorP, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &timer, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &timer, IPhysicalManagerP); virtual void setup_world(WorldP,LocatorP,const DifficultyLevel &); virtual void new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &dLevel, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int humansNum); }; @@ -466,13 +460,13 @@ virtual ScenarioType get_scenario_type() {return JAPAN_TOWN;} virtual int new_level_check(int enemiesPlaying,WorldP,LocatorP, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &timer, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &timer, IPhysicalManagerP); virtual void setup_world(WorldP,LocatorP,const DifficultyLevel &); virtual void new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &dLevel, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int humansNum); virtual void filter_weapons_and_other_items(LocatorP,int &weaponsNum, @@ -581,7 +575,7 @@ int GameStyle::new_level_check(int,WorldP,LocatorP, - int,Boolean &,ostrstream &,Timer &timer, + int,Boolean &,stringstream &,Timer &timer, IPhysicalManagerP) { // A timer-based level. if (timer.ready()) { @@ -791,8 +785,8 @@ -void Normal::describe(ostrstream &str) { - str << "Complete each level/scenario to proceed to the next one." << ends; +void Normal::describe(stringstream &str) { + str << "Complete each level/scenario to proceed to the next one."; } @@ -852,7 +846,7 @@ int Normal::new_level_check(int enemiesPlaying,WorldP w,LocatorP l, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &timer, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &timer, IPhysicalManagerP manager) { GameStyleP delegate = get_delegate(); return delegate->new_level_check(enemiesPlaying,w,l,level,lStrChanged,levelStr,timer,manager); @@ -876,7 +870,7 @@ void Normal::new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &dLevel, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int humansNum) { // Choose which delegate to use. if (level % NORMAL_SCENARIOS_FREQUENCY == 0) { @@ -934,11 +928,10 @@ -void Levels::describe(ostrstream &str) { +void Levels::describe(stringstream &str) { str << "Human player(s) fights through increasing levels of " << "difficulty." << "\n" - << "To complete a level you must kill all enemy players." - << ends; + << "To complete a level you must kill all enemy players."; } @@ -969,7 +962,7 @@ int Levels::new_level_check(int enemiesPlaying,WorldP,LocatorP, - int,Boolean &,ostrstream &,Timer &, + int,Boolean &,stringstream &,Timer &, IPhysicalManagerP) { if (enemiesPlaying == 0) { return 1; @@ -983,7 +976,7 @@ void Levels::new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &dLevel, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int) { world->reset(); @@ -991,8 +984,8 @@ clean_physicals(False,world,locator,manager); - lTitleStr << "[" << level << "] Kill All Machines" << ends; - lStr << "Level: " << level << ends; + lTitleStr << "[" << level << "] Kill All Machines"; + lStr << "Level: " << level; enemiesNum += dLevel.enemiesIncr; enemiesNum = Utils::minimum(enemiesNum,dLevel.enemiesMax); @@ -1037,8 +1030,8 @@ -void KillKillKill::describe(ostrstream &str) { - str << "Every human and machine for him/her/itself." << ends; +void KillKillKill::describe(stringstream &str) { + str << "Every human and machine for him/her/itself."; } @@ -1095,15 +1088,15 @@ void KillKillKill::new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int) { world->reset(); // Don't wipe out the Enemies. clean_physicals(True,world,locator,manager); - lTitleStr << "Level: " << level << ends; - lStr << "Level: " << level << ends; + lTitleStr << "Level: " << level; + lStr << "Level: " << level; // Only create enemies first time or if enemiesRefill is set. if (justReset) { @@ -1152,9 +1145,9 @@ -void Duel::describe(ostrstream &str) { +void Duel::describe(stringstream &str) { str << "Human vs. human battle to the death." - << "\n" << "Each human has 3 lives." << ends; + << "\n" << "Each human has 3 lives."; } @@ -1207,13 +1200,13 @@ void Duel::new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int) { world->reset(); clean_physicals(False,world,locator,manager); - lTitleStr << "Level: " << level << ends; - lStr << "Level: " << level << ends; + lTitleStr << "Level: " << level; + lStr << "Level: " << level; // Only create enemies first time. if (justReset) { @@ -1256,9 +1249,9 @@ -void ExtendedDuel::describe(ostrstream &str) { +void ExtendedDuel::describe(stringstream &str) { str << "Human vs. human battle to the death." - << "\n" << "Unlimited lives." << ends; + << "\n" << "Unlimited lives."; } @@ -1318,13 +1311,13 @@ void ExtendedDuel::new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int) { world->reset(); clean_physicals(False,world,locator,manager); - lTitleStr << "Level: " << level << ends; - lStr << "Level: " << level << ends; + lTitleStr << "Level: " << level; + lStr << "Level: " << level; // Only create enemies first time. if (justReset) { @@ -1367,8 +1360,8 @@ -void Training::describe(ostrstream &str) { - str << "No enemies. Useful for learning the controls." << ends; +void Training::describe(stringstream &str) { + str << "No enemies. Useful for learning the controls."; } @@ -1392,13 +1385,13 @@ void Training::new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int) { world->reset(); clean_physicals(False,world,locator,manager); - lTitleStr << "Level: " << level << ends; - lStr << "Level: " << level << ends; + lTitleStr << "Level: " << level; + lStr << "Level: " << level; } @@ -1428,10 +1421,10 @@ -void Scenarios::describe(ostrstream &str) { +void Scenarios::describe(stringstream &str) { str << "A number of different scenarios." << "\n" << "You must complete each scenario to continue on to the " - << "next one." << ends; + << "next one."; } @@ -1499,7 +1492,7 @@ int Scenarios::new_level_check(int enemiesPlaying,WorldP w,LocatorP l, int level,Boolean &lStrChanged, - ostrstream &levelStr,Timer &timer, + stringstream &levelStr,Timer &timer, IPhysicalManagerP manager) { assert(scenario); return scenario->new_level_check(enemiesPlaying,w,l,level, @@ -1534,7 +1527,7 @@ void Scenarios::new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &dLevel, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int humansNum) { // Works even if scenario is NULL. if (!scenario || scenario->advance_level()) { @@ -1804,7 +1797,7 @@ int Exterminate::new_level_check(int enemiesPlaying,WorldP,LocatorP, - int,Boolean &,ostrstream &,Timer &, + int,Boolean &,stringstream &,Timer &, IPhysicalManagerP) { if (enemiesPlaying == 0) { return 1; @@ -1822,10 +1815,10 @@ void Exterminate::new_level(int level,WorldP,LocatorP, const DifficultyLevel &dLevel, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int) { - lTitleStr << "[" << level << "] EXTERMINATE" << ends; - lStr << "[" << level << "] EXTERMINATE\nKill all machines." << ends; + lTitleStr << "[" << level << "] EXTERMINATE"; + lStr << "[" << level << "] EXTERMINATE\nKill all machines."; // Doesn't increment like LEVELS game style enemiesNum = dLevel.enemiesIncr; @@ -1852,7 +1845,7 @@ int Bonus::new_level_check(int,WorldP,LocatorP locator, int level,Boolean &lStrChanged, - ostrstream &levelStr,Timer &timer, + stringstream &levelStr,Timer &timer, IPhysicalManagerP) { // Ran out of time. if (timer.ready()) { @@ -1873,13 +1866,13 @@ if (remaining != frogsRemaining) { frogsRemaining = remaining; levelStr << "[" << level << "] BONUS LEVEL\nfrogs remaining: " - << remaining << ends; + << remaining; lStrChanged = True; if (remaining > 0) { - ostrstream arenaStr; + stringstream arenaStr; arenaStr << remaining << " Frog" << - (remaining > 1 ? "s" : "") << " Remaining" << ends; - locator->arena_message_enq(arenaStr.str()); + (remaining > 1 ? "s" : "") << " Remaining"; + locator->arena_message_enq(Utils::strdup(arenaStr.str().c_str())); } // Will only be called once per level. @@ -1907,7 +1900,7 @@ void Bonus::new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int) { // Create frogs for (int n = 0; n < SCENARIO_BONUS_FROGS; n++) { @@ -1940,9 +1933,9 @@ frogsRemaining = SCENARIO_BONUS_FROGS; lTitleStr << "[" << level << "] Bonus Level: Kill " - << (int)SCENARIO_BONUS_FROGS << " Frogs" << ends; + << (int)SCENARIO_BONUS_FROGS << " Frogs"; lStr << "[" << level << "] BONUS LEVEL\nfrogs remaining: " - << (int)SCENARIO_BONUS_FROGS << ends; + << (int)SCENARIO_BONUS_FROGS; } @@ -1960,7 +1953,7 @@ int Hive::new_level_check(int,WorldP,LocatorP locator, - int,Boolean &,ostrstream &,Timer &, + int,Boolean &,stringstream &,Timer &, IPhysicalManagerP) { PhysicalP xit = locator->lookup(xitId); assert(xit); // The Xit should never be destroyed. @@ -1987,7 +1980,7 @@ void Hive::new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int) { // Aliens are created in Game::clock. @@ -2012,8 +2005,8 @@ locator->add(egg); } - lTitleStr << "[" << level << "] HIVE" << ends; - lStr << "[" << level << "] HIVE.\nFind the exit." << ends; + lTitleStr << "[" << level << "] HIVE"; + lStr << "[" << level << "] HIVE.\nFind the exit."; } @@ -2073,7 +2066,7 @@ int CaptureTheFlag::new_level_check(int,WorldP,LocatorP locator, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &, IPhysicalManagerP manager) { int fRemaining = 0; for (int n = 0; n < SCENARIO_FLAG_FLAGS; n++) { @@ -2091,19 +2084,19 @@ flagsRemaining = fRemaining; levelStr << "[" << level << "] COLLECT " << (int)SCENARIO_FLAG_FLAGS - << " FLAGS\nremaining: "<< flagsRemaining << ends; + << " FLAGS\nremaining: "<< flagsRemaining; lStrChanged = True; - ostrstream arenaStr; + stringstream arenaStr; if (fRemaining != 0) { arenaStr << flagsRemaining << " Flag" << - (flagsRemaining > 1 ? "s" : "") << " Remaining" << ends; + (flagsRemaining > 1 ? "s" : "") << " Remaining"; } else { - arenaStr << "All Flags Collected" << ends; + arenaStr << "All Flags Collected"; } - locator->arena_message_enq(arenaStr.str()); + locator->arena_message_enq(Utils::strdup(arenaStr.str().c_str())); } if (fRemaining == 0) { // All flags are gone, so end level. @@ -2124,7 +2117,7 @@ void CaptureTheFlag::new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP,int) { for (int n = 0; n < SCENARIO_FLAG_FLAGS; n++) { Pos pos = world->empty_accessible_rect(Flag::get_size_max()); @@ -2136,9 +2129,9 @@ flagsRemaining = SCENARIO_FLAG_FLAGS; lTitleStr << "[" << level << "] Capture The Flag: " - << (int)SCENARIO_FLAG_FLAGS << " Flags" << ends; + << (int)SCENARIO_FLAG_FLAGS << " Flags"; lStr << "[" << level << "] COLLECT " << (int)SCENARIO_FLAG_FLAGS - << " FLAGS.\nremaining: " << (int)SCENARIO_FLAG_FLAGS << ends; + << " FLAGS.\nremaining: " << (int)SCENARIO_FLAG_FLAGS; } @@ -2169,7 +2162,7 @@ void GenericSeals::new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP,int) { // Add a team for each human in the game. // Don't use locator->humans_registered() because they may not have been @@ -2298,7 +2291,7 @@ int Seals::new_level_check(int,WorldP,LocatorP locator, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &, IPhysicalManagerP) { int lemOut,lemSafe,lemActive,lemDead; compute_out_safe_active_dead(locator,lemOut,lemSafe,lemActive,lemDead); @@ -2312,10 +2305,10 @@ // Only update arena string if sealsSafe has changed. if (lemSafe != sealsSafe && lemSafe != SCENARIO_SEALS_NEED) { - ostrstream arenaStr; + stringstream arenaStr; arenaStr << "Save " << (SCENARIO_SEALS_NEED - lemSafe) - << " More Baby Seals" << ends; - locator->arena_message_enq(arenaStr.str()); + << " More Baby Seals"; + locator->arena_message_enq(Utils::strdup(arenaStr.str().c_str())); } sealsSafe = lemSafe; @@ -2324,18 +2317,17 @@ levelStr << "[" << level << "] SAVE " << (int)SCENARIO_SEALS_NEED << " BABY SEALS\n" << "out: " << sealsOut << " safe: " << sealsSafe - << " dead: " << lemDead - << ends; + << " dead: " << lemDead; lStrChanged = True; // New level if enough seals are safe or too many are dead. if (lemDead > (SCENARIO_SEALS_SEALS - SCENARIO_SEALS_NEED) || lemSafe >= SCENARIO_SEALS_NEED) { if (lemSafe < SCENARIO_SEALS_NEED) { - ostrstream msg; + stringstream msg; msg << "YOU FAILED TO SAVE " << (int)SCENARIO_SEALS_NEED - << " BABY SEALS. TRY THIS LEVEL AGAIN." << ends; - locator->arena_message_enq(msg.str()); + << " BABY SEALS. TRY THIS LEVEL AGAIN."; + locator->arena_message_enq(Utils::strdup(msg.str().c_str())); } else { locator->arena_message_enq(Utils::strdup("Good work. Go to the next level.")); @@ -2365,11 +2357,10 @@ -void Seals::set_level_strings(int level,ostrstream &lStr,ostrstream &lTitleStr) { - lTitleStr << "[" << level << "] SAVE THE BABY SEALS" << ends; +void Seals::set_level_strings(int level,stringstream &lStr,stringstream &lTitleStr) { + lTitleStr << "[" << level << "] SAVE THE BABY SEALS"; lStr << "[" << level << "] SAVE "<< - (int)SCENARIO_SEALS_NEED << " BABY SEALS\n" - << "out: 0 safe: 0 dead: 0" << ends; + (int)SCENARIO_SEALS_NEED << " BABY SEALS\n" << "out: 0 safe: 0 dead: 0"; } @@ -2430,7 +2421,7 @@ int AntiSeals::new_level_check(int,WorldP,LocatorP locator, - int level,Boolean &lStrChanged,ostrstream &levelStr,Timer &, + int level,Boolean &lStrChanged,stringstream &levelStr,Timer &, IPhysicalManagerP) { // level not over by default. int ret = -1; @@ -2441,15 +2432,13 @@ // Failure if (lemSafe > SCENARIO_ANTI_SEALS_MAX_SLIPPAGE) { - ostrstream msg; #if 0 // Not enough space on screen, need two lines. msg << "YOU LET TOO MANY OF THE FAT BASTARDS GET AWAY\n" << "Try this level again" << ends; #else - msg << "YOU LET TOO MANY OF THE FAT BASTARDS GET AWAY" << ends; #endif - locator->arena_message_enq(msg.str()); + locator->arena_message_enq(Utils::strdup("YOU LET TOO MANY OF THE FAT BASTARDS GET AWAY")); // start new level ret = 1; @@ -2473,13 +2462,11 @@ } // Update UI else if (lemSafe == sealsSafe) { // o.w. the "one got away" message takes priority - ostrstream arenaStr; - arenaStr << "Kill " - << lemToKill << " More Baby Seals" << ends; - locator->arena_message_enq(arenaStr.str()); + stringstream arenaStr; + arenaStr << "Kill " << lemToKill << " More Baby Seals"; + locator->arena_message_enq(Utils::strdup(arenaStr.str().c_str())); - levelStr << "[" << level << "] KILL " - << lemToKill << " BABY SEALS" << ends; + levelStr << "[" << level << "] KILL " << lemToKill << " BABY SEALS"; lStrChanged = True; } } // lemDead != sealsDead @@ -2502,10 +2489,10 @@ -void AntiSeals::set_level_strings(int level,ostrstream &lStr,ostrstream &lTitleStr) { - lTitleStr << "[" << level << "] KILL THE BABY SEALS" << ends; +void AntiSeals::set_level_strings(int level,stringstream &lStr,stringstream &lTitleStr) { + lTitleStr << "[" << level << "] KILL THE BABY SEALS"; lStr << "[" << level << "] KILL "<< - (int)SCENARIO_SEALS_SEALS << " BABY SEALS" << ends; + (int)SCENARIO_SEALS_SEALS << " BABY SEALS"; } @@ -2552,7 +2539,7 @@ int KillTheFireDemon::new_level_check(int enemiesPlaying,WorldP,LocatorP locator, - int,Boolean &,ostrstream &,Timer &, + int,Boolean &,stringstream &,Timer &, IPhysicalManagerP) { if (enemiesPlaying == 0) { locator->arena_message_enq(Utils::strdup("Take That, You Mother-Fucking Spawn From Hell")); @@ -2572,12 +2559,12 @@ void KillTheFireDemon::new_level(int level,WorldP,LocatorP, const DifficultyLevel &, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int) { manager->create_enemy(manager->enemy_physical(A_FireDemon)); - lTitleStr << "[" << level << "] FIRE DEMON" << ends; - lStr << "[" << level << "] Kill the Fire Demon." << ends; + lTitleStr << "[" << level << "] FIRE DEMON"; + lStr << "[" << level << "] Kill the Fire Demon."; } @@ -2594,7 +2581,7 @@ int KillTheDragon::new_level_check(int enemiesPlaying,WorldP,LocatorP locator, - int,Boolean &,ostrstream &,Timer &, + int,Boolean &,stringstream &,Timer &, IPhysicalManagerP) { if (enemiesPlaying == 0) { locator->arena_message_enq(Utils::strdup("The Infernal Worm has been vanquished")); @@ -2614,7 +2601,7 @@ void KillTheDragon::new_level(int level,WorldP w,LocatorP l, const DifficultyLevel &, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int) { const PhysicalContext *cx = &Dragon::creatureContext.movingContext.physicalContext; Pos pos = w->empty_rect(cx->sizeMax); @@ -2628,8 +2615,8 @@ manager->create_enemy(p,False); } - lTitleStr << "[" << level << "] Dragon" << ends; - lStr << "[" << level << "] Kill the Dragon." << ends; + lTitleStr << "[" << level << "] Dragon"; + lStr << "[" << level << "] Kill the Dragon."; } @@ -2667,7 +2654,7 @@ int ZigZag::new_level_check(int,WorldP world,LocatorP locator, - int,Boolean &,ostrstream &,Timer &, + int,Boolean &,stringstream &,Timer &, IPhysicalManagerP) { PhysicalP xit = locator->lookup(xitId); assert(xit); // The Xit should never be destroyed. @@ -2680,7 +2667,7 @@ HumanP human = locator->get_human(n); if (human) { // previous depth - int depthOld = (int)human->get_data(); + long depthOld = (long)human->get_data(); Id id = human->get_id(); // Get physical for intelligence @@ -2697,9 +2684,9 @@ human->set_data((void *)depth); // Use 1-based counting for the User. - ostrstream str; - str << "Depth " << (depth + 1) << ends; - locator->arena_message_enq(str.str(),p); + stringstream str; + str << "Depth " << (depth + 1); + locator->arena_message_enq(Utils::strdup(str.str().c_str()),p); } } } @@ -2718,7 +2705,7 @@ void ZigZag::new_level(int level,WorldP world,LocatorP locator, const DifficultyLevel &, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP,int) { Rooms worldRooms = world->get_rooms(); RoomIndex upperRight(0,worldRooms.acrossMax - 1); @@ -2731,9 +2718,8 @@ xitId = p->get_id(); // 1-based counting of depth for the user. - lTitleStr << "[" << level << "] ZIG-ZAG: Depth " - << worldRooms.downMax << ends; - lStr << "[" << level << "] ZIG-ZAG.\nFind the exit." << ends; + lTitleStr << "[" << level << "] ZIG-ZAG: Depth " << worldRooms.downMax; + lStr << "[" << level << "] ZIG-ZAG.\nFind the exit."; } @@ -2761,7 +2747,7 @@ int ThePound::new_level_check(int enemiesPlaying,WorldP,LocatorP locator, - int,Boolean &,ostrstream &,Timer &, + int,Boolean &,stringstream &,Timer &, IPhysicalManagerP) { if (enemiesPlaying == 0) { locator->arena_message_enq(Utils::strdup("Killed the Mutts")); @@ -2781,7 +2767,7 @@ void ThePound::new_level(int level,WorldP,LocatorP locator, const DifficultyLevel &, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int) { locator->add_team(Scenarios::dog_team,NULL); @@ -2789,8 +2775,8 @@ manager->create_enemy(manager->enemy_physical(A_Dog)); } - lTitleStr << "[" << level << "] The Pound" << ends; - lStr << "[" << level << "] The Pound" << ends; + lTitleStr << "[" << level << "] The Pound"; + lStr << "[" << level << "] The Pound"; } @@ -2801,7 +2787,7 @@ int JapanTown::new_level_check(int enemiesPlaying,WorldP,LocatorP locator, - int,Boolean &,ostrstream &,Timer &, + int,Boolean &,stringstream &,Timer &, IPhysicalManagerP) { if (enemiesPlaying == 0) { locator->arena_message_enq(Utils::strdup("Damn Ninjas. Worse than roaches.")); @@ -2821,7 +2807,7 @@ void JapanTown::new_level(int level,WorldP,LocatorP locator, const DifficultyLevel &, - ostrstream &lStr,ostrstream &lTitleStr, + stringstream &lStr,stringstream &lTitleStr, IPhysicalManagerP manager,int) { locator->add_team(JapanTown::ninja_team,NULL); @@ -2829,8 +2815,8 @@ manager->create_enemy(manager->enemy_physical(A_Ninja)); } - lTitleStr << "[" << level << "] Japan-Town" << ends; - lStr << "[" << level << "] Japan-Town" << ends; + lTitleStr << "[" << level << "] Japan-Town"; + lStr << "[" << level << "] Japan-Town"; } --- xevil-2.02r2.orig/cmn/game.cpp +++ xevil-2.02r2/cmn/game.cpp @@ -31,16 +31,17 @@ #include "stdafx.h" extern "C" { #include +#include } #if X11 -#include +#include #endif #if WIN32 #include #endif -#include +#include #include "utils.h" #include "coord.h" @@ -271,6 +272,14 @@ "Prepare to Qualify.", "I got a bad feeling about this drop.", "Cowboys never quit!", + "The voices say I'm not crazy, so I'm OK!", + "Cure Sars!?!", + "Ha Ha Ha, Loser!", + "It's all fun and games until someone loses an eye.", + "Eye for an eye, tooth for a tooth.", + "Mo-o-m!", + "Timmy's touching me!", + "I'm not touching you! See? I'm not touching you!" }; @@ -350,6 +359,9 @@ "Stan", "Mr. Hat", "Cid", + "Mr. Hankey", + "Michael Jackson", + "O.J. Simpson" }; @@ -793,7 +805,7 @@ // Just for tracing in the debugger. char* version = Utils::get_OS_info(); - delete version; + delete [] version; noUi = False; noNewLevel = False; @@ -1056,7 +1068,7 @@ Game::~Game() { if (oneItem) { - delete oneItem; + delete [] oneItem; } delete ui; @@ -1500,13 +1512,13 @@ if (mask & UIconnectServer) { delete role; - ostrstream portName; - portName << settings.connectPort << ends; + stringstream portName; + portName << settings.connectPort; IViewportInfo* vInfo = Ui::get_viewport_info(); - ClientP client = new Client(settings.connectHostname,portName.str(), + ClientP client = new Client(settings.connectHostname, + Utils::strdup(portName.str().c_str()), 0,settings.humanName,vInfo, Connection::ADJUST_SKIP,&locator); - delete portName.str(); assert(client); role = client; ui->set_role_type(role->get_type()); @@ -1544,10 +1556,9 @@ } delete role; - ostrstream portName; - portName << settings.serverPort << ends; - role = new Server(settings.localHuman,portName.str(),&locator); - delete portName.str(); + stringstream portName; + portName << settings.serverPort; + role = new Server(settings.localHuman,portName.str().c_str(),&locator); assert(role); restartEnd = RE_RESTART; ui->set_role_type(role->get_type()); @@ -1573,9 +1584,9 @@ ui->set_style(styleType); } - ostrstream str; + stringstream str; styleNext->describe(str); - locator.message_enq(str.str()); + locator.message_enq(Utils::strdup(str.str().c_str())); } @@ -1589,9 +1600,9 @@ human->reincarnate(); obj->set_intel(human); - ostrstream msg; - msg << human->get_name() << " is back from the dead." << ends; - locator.message_enq(msg.str()); + stringstream msg; + msg << human->get_name() << " is back from the dead."; + locator.message_enq(Utils::strdup(msg.str().c_str())); } } @@ -1615,7 +1626,7 @@ void Game::new_level_check(int enemiesPlaying) { assert(state == gameOn); - ostrstream str; + stringstream str; Boolean lStrChanged = False; int val = style->new_level_check(enemiesPlaying,&world,&locator, level,lStrChanged,str,timer, @@ -1645,11 +1656,8 @@ // if str has anything in it. Fucking Linux compilers. if (lStrChanged) { if (ui) { - ui->set_level(str.str()); + ui->set_level(str.str().c_str()); } - // Ok to delete even if ui is NULL, str.str() will allocate the memory to - // kill off. - delete str.str(); } } @@ -1876,7 +1884,7 @@ if (showMessages) { for (int n = 0; n < locator.humans_registered(); n++) { HumanP human = locator.get_human(n); - ostrstream msg; + stringstream msg; // Soups are only taken into account if you have unlimited lives. int totalKills; @@ -1896,9 +1904,9 @@ char *ranking = choose_ranking(totalKills); msg << totalKills << (totalKills == 1 ? "Kill" : " Kills") - << ", Rank: " << ranking << ends; + << ", Rank: " << ranking; IntelId humanIntelId = human->get_intel_id(); - locator.arena_message_enq(msg.str(),&humanIntelId,10000); + locator.arena_message_enq(Utils::strdup(msg.str().c_str()),&humanIntelId,10000); } } } @@ -1919,8 +1927,8 @@ // Will clean out non-persistent teams. locator.level_reset(); - ostrstream lStr; // For level box on the side of the ui-> - ostrstream lTitleStr; // For Ui title screen. + stringstream lStr; // For level box on the side of the ui-> + stringstream lTitleStr; // For Ui title screen. Boolean doBonus; // Possibly increment level count number. @@ -1960,7 +1968,7 @@ if (doBonus) { delete levelTitleStored; // If it already exists. // Store levelTitle string for later use. - levelTitleStored = lTitleStr.str(); + levelTitleStored = Utils::strdup(lTitleStr.str().c_str()); // Tell user about the bonus. award_bonuses_now(); @@ -1970,13 +1978,12 @@ } // Go to getBearings state. else { - get_bearings(lTitleStr.str()); + get_bearings(Utils::strdup(lTitleStr.str().c_str())); } if (ui) { - ui->set_level(lStr.str()); + ui->set_level(lStr.str().c_str()); } - delete lStr.str(); // Will pass in more info later. role->new_level(this,&world,&locator); @@ -2184,9 +2191,9 @@ // Moved resetting world rooms to new_level(); - ostrstream msg; - msg << wittySayings[Utils::choose(WITTY_SAYINGS_NUM)] << ends; - locator.message_enq(msg.str()); + stringstream msg; + msg << wittySayings[Utils::choose(WITTY_SAYINGS_NUM)]; + locator.message_enq(Utils::strdup(msg.str().c_str())); /* Don't need to call Ui::set_* because the new values originally came from ui-> */ @@ -2242,12 +2249,12 @@ { // Right keys. right[n][which] = 0; - ostrstream strm; + stringstream strm; if (which == 0) - strm << "right_" << keysNames[n] << ends; + strm << "right_" << keysNames[n]; else - strm << "right_" << keysNames[n] << "_2" << ends; - char *option = strm.str(); + strm << "right_" << keysNames[n] << "_2"; + const char *option = strm.str().c_str(); // Should we free value?? char *value = XGetDefault(ui->get_dpy(0),XEVIL_CLASS,option); @@ -2256,18 +2263,17 @@ if (keysym != NoSymbol) right[n][which] = keysym; } - delete option; } { // Left Keys. left[n][which] = 0; - ostrstream strm; + stringstream strm; if (which == 0) - strm << "left_" << keysNames[n] << ends; + strm << "left_" << keysNames[n]; else - strm << "left_" << keysNames[n] << "_2" << ends; - char *option = strm.str(); + strm << "left_" << keysNames[n] << "_2"; + const char *option = strm.str().c_str(); // Should we free value?? char *value = XGetDefault(ui->get_dpy(0),XEVIL_CLASS,option); @@ -2276,7 +2282,6 @@ if (keysym != NoSymbol) left[n][which] = keysym; } - delete option; } } @@ -2291,10 +2296,10 @@ void Game::parse_args(int *argc,char **argv) { // Create a bunch of "-name" strings for comparing with command-line // args. - ostrstream dashName[Locator::HUMANS_MAX]; + stringstream dashName[Locator::HUMANS_MAX]; int n; for (n = 0; n < Locator::HUMANS_MAX; n++) { - dashName[n] << "-name" << n << ends; + dashName[n] << "-name" << n; } // Defaults @@ -2351,7 +2356,7 @@ // Check "-name" arguments. else { for (int j = 0; j < Locator::HUMANS_MAX; j++) { - if ((! strcmp(dashName[j].str(),argv[n])) && (n + 1 < *argc)) { + if ((! strcmp(dashName[j].str().c_str(),argv[n])) && (n + 1 < *argc)) { humanNames[j] = Utils::strdup(argv[n+1]); n++; } @@ -2728,12 +2733,6 @@ n++; } } // for - - - // Delete memory for "-name" strings. - for (n = 0; n < Locator::HUMANS_MAX; n++) { - delete dashName[n].str(); - } } @@ -2741,15 +2740,15 @@ char **Game::display_names(int *argc,char **argv) { #if X11 - ostrstream dashDisplay[UI_VIEWPORTS_MAX][2]; + stringstream dashDisplay[UI_VIEWPORTS_MAX][2]; char **displayNames = new charP [UI_VIEWPORTS_MAX]; int n; for (n = 0; n < UI_VIEWPORTS_MAX; n++) { displayNames[n] = new char [Xvars::DISPLAY_NAME_LENGTH]; strcpy(displayNames[n],""); - dashDisplay[n][0] << "-display" << n << ends; - dashDisplay[n][1] << "-d" << n << ends; + dashDisplay[n][0] << "-display" << n; + dashDisplay[n][1] << "-d" << n; } // Loop through all command line arguments. @@ -2765,7 +2764,7 @@ // Set display name for one viewport. for (int m = 0; m < UI_VIEWPORTS_MAX; m++) { for (int which = 0; which < 2; which++) { - if (!strcmp(argv[n],dashDisplay[m][which].str())) { + if (!strcmp(argv[n],dashDisplay[m][which].str().c_str())) { assert(strlen(argv[n+1]) < Xvars::DISPLAY_NAME_LENGTH); strcpy(displayNames[m],argv[n+1]); } @@ -2773,11 +2772,6 @@ } } - for (n = 0; n < UI_VIEWPORTS_MAX; n++) { - for (int which = 0; which < 2; which++) { - delete dashDisplay[n][which].str(); - } - } return displayNames; #endif @@ -2954,13 +2948,12 @@ // Put message in the status bar when the game starts up. // Use \n in string for locator.message_enq. - ostrstream msg; + stringstream msg; msg << "XEvil(TM) " << VERSION << " http://www.xevil.com satan@xevil.com " << XETP::versionStr << "\n" - << "Copyright(C) 1994,2000 Steve Hardt and Michael Judge" - << ends; - locator.message_enq(msg.str()); + << "Copyright(C) 1994,2000 Steve Hardt and Michael Judge"; + locator.message_enq(Utils::strdup(msg.str().c_str())); // Print message to standard out. Doesn't really do anything on Windows. @@ -3075,11 +3068,10 @@ IntelOptions ops; ITmask opMask = intel_options_for(ops,obj->get_class_id()); - ostrstream name; - name << "Machine-" << (enemyNameCount++) << ends; - EnemyP enemy = new Enemy(&world,&locator,name.str(),&ops,opMask); + stringstream name; + name << "Machine-" << (enemyNameCount++); + EnemyP enemy = new Enemy(&world,&locator,name.str().c_str(),&ops,opMask); assert(enemy); - delete name.str(); locator.register_enemy(enemy); if (addToLocator) { @@ -3235,14 +3227,13 @@ switch (Utils::choose(8)) { case 0: { // A bunch of Heros and an Alien. for (int n = 0; n < 10; n++) { - ostrstream name; - name << "Enemy-" << n << ends; + stringstream name; + name << "Enemy-" << n; IntelOptions ops; ops.harmless = True; - EnemyP enemy = new Enemy(&world,&locator,name.str(), + EnemyP enemy = new Enemy(&world,&locator,name.str().c_str(), &ops,ITharmless); assert(enemy); - delete name.str(); locator.register_enemy(enemy); Pos pos = world.empty_rect(Hero::get_size_max()); @@ -3268,16 +3259,15 @@ case 1: { // Hero, FThrower, and a bunch of Frogs (does not mean Frenchmen). for (int n = 0; n < 15; n++) { - ostrstream name; - name << "Enemy-" << n << ends; + stringstream name; + name << "Enemy-" << n; IntelOptions ops; ops.psychotic = Utils::coin_flip(); - EnemyP enemy = new Enemy(&world,&locator,name.str(), + EnemyP enemy = new Enemy(&world,&locator,name.str().c_str(), &ops,ITpsychotic); assert(enemy); - delete name.str(); locator.register_enemy(enemy); - + Pos pos = world.empty_rect(Frog::get_size_max()); PhysicalP obj = new Frog(&world,&locator,pos); assert(obj); @@ -3304,15 +3294,14 @@ case 2: { // A bunch of Enforcers. for (int n = 0; n < 10; n++) { - ostrstream name; - name << "Enemy-" << n << ends; + stringstream name; + name << "Enemy-" << n; IntelOptions ops; ops.classFriends = False; ops.psychotic = True; - EnemyP enemy = new Enemy(&world,&locator,name.str(), + EnemyP enemy = new Enemy(&world,&locator,name.str().c_str(), &ops,ITclassFriends|ITpsychotic); assert(enemy); - delete name.str(); locator.register_enemy(enemy); Pos pos = world.empty_rect(Enforcer::get_size_max()); @@ -3327,14 +3316,13 @@ case 3: { // A bunch of Ninjas and a chainsaw. for (int n = 0; n < 10; n++) { - ostrstream name; - name << "Enemy-" << n << ends; + stringstream name; + name << "Enemy-" << n; IntelOptions ops; ops.classFriends = False; - EnemyP enemy = new Enemy(&world,&locator,name.str(), + EnemyP enemy = new Enemy(&world,&locator,name.str().c_str(), &ops,ITclassFriends); assert(enemy); - delete name.str(); locator.register_enemy(enemy); Pos pos = world.empty_rect(Ninja::get_size_max()); @@ -3373,12 +3361,11 @@ } for (int m = 0; m < 10; m++) { - ostrstream name; - name << "Enemy-" << m << ends; - EnemyP enemy = new Enemy(&world,&locator,name.str(), + stringstream name; + name << "Enemy-" << m; + EnemyP enemy = new Enemy(&world,&locator,name.str().c_str(), NULL,ITnone); assert(enemy); - delete name.str(); locator.register_enemy(enemy); Pos pos = world.empty_rect(Hero::get_size_max()); @@ -3414,14 +3401,13 @@ case 5: { // Ninjas and ChopperBoys. int n; for (n = 0; n < 10; n++) { - ostrstream name; - name << "Enemy-" << n << ends; + stringstream name; + name << "Enemy-" << n; IntelOptions ops; ops.classFriends = False; - EnemyP enemy = new Enemy(&world,&locator,name.str(), + EnemyP enemy = new Enemy(&world,&locator,name.str().c_str(), &ops,ITclassFriends); assert(enemy); - delete name.str(); locator.register_enemy(enemy); PhysicalP obj; @@ -3458,11 +3444,10 @@ // and the scenario isn't set up yet. for (n = 0; n < 9; n++) { - ostrstream name; - name << "Dog-" << n << ends; - EnemyP intel = new Enemy(&world,&locator,name.str(),NULL,ITnone); + stringstream name; + name << "Dog-" << n; + EnemyP intel = new Enemy(&world,&locator,name.str().c_str(),NULL,ITnone); assert(intel); - delete name.str(); locator.register_enemy(intel); Pos pos = world.empty_rect(Dog::get_size_max()); @@ -3473,13 +3458,12 @@ } for (n = 0; n < 3; n++) { - ostrstream name; - name << "Enemy-" << n << ends; + stringstream name; + name << "Enemy-" << n; IntelOptions ops; ops.harmless = True; - EnemyP enemy = new Enemy(&world,&locator,name.str(),&ops,ITharmless); + EnemyP enemy = new Enemy(&world,&locator,name.str().c_str(),&ops,ITharmless); assert(enemy); - delete name.str(); locator.register_enemy(enemy); PhysicalP obj; @@ -3510,13 +3494,12 @@ Segmented::create_and_add_composite(ret,&world,&locator,Dragon::SEGMENTS_NUM,pos, Dragon::create,NULL); for (int m = 0; m < ret.length(); m++) { - ostrstream name; - name << "Enemy-" << n << ends; + stringstream name; + name << "Enemy-" << n; IntelOptions ops; ops.harmless = True; - EnemyP enemy = new Enemy(&world,&locator,name.str(),&ops,ITharmless); + EnemyP enemy = new Enemy(&world,&locator,name.str().c_str(),&ops,ITharmless); assert(enemy); - delete name.str(); locator.register_enemy(enemy); PhysicalP p = (PhysicalP)ret.get(m); p->set_intel(enemy); --- xevil-2.02r2.orig/debian/rules +++ xevil-2.02r2/debian/rules @@ -0,0 +1,65 @@ +#!/usr/bin/make -f + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +DEBUG_OPT = -Wno-trigraphs -Wno-write-strings -g +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + DEBUG_OPT += -O0 +else + DEBUG_OPT += -O2 +endif + +export FORCEHOSTTYPE=debian-linux + +build: build-stamp +build-stamp: + dh_testdir + + $(MAKE) DEBUG_OPT="$(DEBUG_OPT)" + + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + + -$(MAKE) clean + -rm -rf x11/release + -rm x11/bitmaps/ui/xevil.xpm + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + mv x11/release/serverping x11/release/xevil-serverping + dh_install x11/release/xevil x11/release/xevil-serverping usr/games + cp x11/bitmaps/ui/xevil_icon.xpm x11/bitmaps/ui/xevil.xpm + dh_install x11/bitmaps/ui/xevil.xpm usr/share/pixmaps + +binary-indep: build install + +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installmenu + dh_installman debian/xevil.6 debian/xevil-serverping.6 + dh_link + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install --- xevil-2.02r2.orig/debian/watch +++ xevil-2.02r2/debian/watch @@ -0,0 +1,2 @@ +version=2 +http://www.xevil.com/download/stable/xevilsrc(.*)\.zip --- xevil-2.02r2.orig/debian/copyright +++ xevil-2.02r2/debian/copyright @@ -0,0 +1,25 @@ +This package was debianized by Ben C. Hendrickson on +Thursday, 20 Jan 2000 5:48:08 -0700. + +It was downloaded from ftp://ftp.xevil.com/developer/xevilsrc2.02p2.zip + +Upstream Author: Steve Hardt + +Copyright (C) 1994, 2000 Steve Hardt and Michael Judge + +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +On Debian systems, the complete text of the GNU General Public +License can be found in /usr/share/common-licenses/GPL file. --- xevil-2.02r2.orig/debian/changelog +++ xevil-2.02r2/debian/changelog @@ -0,0 +1,199 @@ +xevil (2.02r2-8) unstable; urgency=low + + * Removed bashism from rule file (Closes: #459141) + * Added menu and pixmap + * renamed serverping to xevil-serverping + * replaced dependency on transitional package x-dev with x11proto-core-dev + * Set Standards-Version to 3.7.3 (modified menu to put xevil in + Games/Action rather than Games/Arcade) + * xevil-serverping no longer unnecessarily links against libXpm and libX11 + + -- Brandon Barnes Fri, 18 Jan 2008 01:22:00 -0800 + +xevil (2.02r2-7) unstable; urgency=low + + * Fixed broken network (Closes: #240311) + * Hopefully, fixed munmap_chunk(): invalid pointer crash at startup + which some users were experiencing. + * Commented out assert that was causing early server abort in network + games (Closes: #94326) + + -- Brandon Barnes Tue, 22 May 2007 11:33:00 -0700 + +xevil (2.02r2-6) unstable; urgency=low + + * Removed forced license agreement before every play. + * Added keyboard shortcuts for common menu items + * Suppressed compiler white noise + * Added some "witty" sayings and names + * Added xevil man page + * Minor, misc fixes/improvements + + -- Brandon Barnes Sat, 20 Jan 2007 3:24:00 -0800 + +xevil (2.02r2-5) unstable; urgency=low + + * New Maintainer (Closes: #353389) + + -- Brandon Barnes Sat, 16 Dec 2006 09:23:00 -0800 + +xevil (2.02r2-4) unstable; urgency=low + + * QA upload. + * Package is orphaned (#353389); set maintainer to Debian QA Group. + * Acknowledge NMU. Closes: #346813. + * Fix build failure with g++ 4.1. Thanks to Martin Michlmayr for + the patch. Closes: #356321. + * Switch to debhelper 5. + * debian/changelog: Remove obsolete Emacs local variables. + * debian/rules: Add support for DEB_BUILD_OPTIONS=noopt. + * debian/watch: Add. + * Conforms to Standards version 3.6.2. + + -- Matej Vela Sat, 11 Mar 2006 23:38:44 +0100 + +xevil (2.02r2-3.1) unstable; urgency=low + + * Non-maintainer upload to help xlibs-dev transition. + * debian/control: Replaced xlibs-dev build-dep. (Closes: #346813) + + -- Marc 'HE' Brockschmidt Fri, 20 Jan 2006 16:57:12 +0100 + +xevil (2.02r2-3) unstable; urgency=low + + * Fix compilation with g++ 4.0 (Closes: #297848) + + -- Aaron Lehmann Fri, 22 Jul 2005 15:53:10 -0700 + +xevil (2.02r2-2) unstable; urgency=low + + * Fix a memory leak. + + -- Aaron Lehmann Sat, 21 Jun 2003 22:57:26 -0700 + +xevil (2.02r2-1) unstable; urgency=low + + * New upstream version. Nothing new, just merging. + + -- Aaron Lehmann Sat, 21 Jun 2003 22:18:34 -0700 + +xevil (2.02-6) unstable; urgency=low + + * Total revamp to build with modern C++ implementations. (Closes: #196314) + + -- Aaron Lehmann Sat, 07 Jun 2003 17:02:56 -0700 + +xevil (2.02-5) unstable; urgency=low + + * Remove platform support information from long description + * Bump Standards-Version + * Build with g++ 3.2! + + -- Aaron Lehmann Tue, 07 Jan 2003 15:14:40 -0800 + +xevil (2.02-4.1) unstable; urgency=low + + * NMU + * x11/main.cpp: add #include for exit() prototype + * x11/serverping.cpp: same + * x11/ui.cpp: same + * cmn/game.cpp: same + * now builds on ia64 + + -- Branden Robinson Fri, 28 Sep 2001 16:16:19 -0500 + +xevil (2.02-4) unstable; urgency=low + + * Adopted package (Closes: #108634) + * Bumped Standards-Version + * Removed to call to dh_suidregister + * g++-3.0 compile fixes, w/ help from Andrew Suffield + + * Return 0 from main + + -- Aaron Lehmann Sun, 19 Aug 2001 10:48:09 -0700 + +xevil (2.02-3) unstable; urgency=low + + * Oprhaned the package. Ben Hendrickson was someone I sponsored but + never heard much of him. Since his mail account is no more valid + I decided to orphan xevil. + * Added Build-Depends (there was none so the bug report shouldn't be + of severity important, but well...) Closes: #104857 + * Recompiled with latest libs. Closes: #97418 + * xevil starts fine. Closes: #101814 + + -- Raphael Hertzog Sun, 12 Aug 2001 21:06:56 +0200 + +xevil (2.02-2) frozen unstable; urgency=low + + * Removed building the .tar.Z. It was both superfluous and depenant on the non-free compress program. (Closes: #56786) + + -- Ben C. Hendrickson Fri, 4 Feb 2000 09:40:33 -0800 + +xevil (2.02-1) frozen unstable; urgency=low + + * Steve Hardt made a GPL'ed release for us. Yeah! (Closes: #50409, #52150) + * Fixed constness errors in intel.cpp and ui.cpp. (Closes: #46485, #53465) + * Made menu title uppercase. + + -- Ben C. Hendrickson Wed, 19 Jan 2000 21:09:44 -0800 + +xevil (2.01-1) unstable; urgency=low + + * New maintainer waiting to be registered as an offical debian + developer. Raphael Hertzog is acting as a sponsor for the + time being. + * New upstream version. Unfortunately, it is now shareware + moving it to non-free. + * Completely repacked with debhelper. + * Upgraded standards-version to 2.5.1. + + -- Ben C. Hendrickson Wed, 19 Jan 2000 21:09:32 -0800 + +xevil (1.5.1e-2.3) frozen unstable; urgency=low + + * Non-maintainer upload. + * Rebuilt in a potato environment to fix segfault problems. + * Tweaked package description a bit. + * Fixes: #37310 + + -- Branden Robinson Mon, 31 May 1999 10:18:14 -0400 + +xevil (1.5.1e-2.2) frozen unstable; urgency=low + + * Non maintainer upload. + * Recompiled with g++/libstdc++2.9 (for i386). + * Makefile: New target debian-linux to compile on all architectures. + * debian/rules: Call it (with DEBUG_OPT instead CFLAGS). + + -- Matthias Klose Mon, 14 Dec 1998 14:38:47 +0200 + +xevil (1.5.1e-2.1) unstable; urgency=low + + * NMU to link against libstdc++2.9 + * Added multi-arch support to debian/rules (from fixed i386-linux target) + * Also added alpha-linux support to Makefile + + -- Christopher C. Chimelis Tue, 30 Sep 1998 16:35:22 -0500 + +xevil (1.5.1e-2) unstable; urgency=low + + * update standards-version + * change email address to a working one (finally) + * list new FSF address. + + -- Igor Grobman Tue, 10 Feb 1998 15:01:06 -0500 + +xevil (1.5.1e-1.1) unstable; urgency=low + + * Non-maintainer release. + * Libc6 compile. + + -- Martin Mitchell Wed, 12 Nov 1997 05:04:55 +1100 + +xevil (1.5.1e-1) unstable; urgency=low + + * Initial Release. + + -- Igor Grobman Tue, 7 Jan 1997 01:28:55 -0500 --- xevil-2.02r2.orig/debian/compat +++ xevil-2.02r2/debian/compat @@ -0,0 +1 @@ +5 --- xevil-2.02r2.orig/debian/docs +++ xevil-2.02r2/debian/docs @@ -0,0 +1,3 @@ +classes.txt +readme.txt +instructions --- xevil-2.02r2.orig/debian/menu +++ xevil-2.02r2/debian/menu @@ -0,0 +1,3 @@ +?package(xevil):needs="X11" section="Games/Action" \ + title="XEvil" description="Kill 'em all in hell." \ + command="/usr/games/xevil" icon="/usr/share/pixmaps/xevil.xpm" --- xevil-2.02r2.orig/debian/control +++ xevil-2.02r2/debian/control @@ -0,0 +1,18 @@ +Source: xevil +Section: games +Priority: optional +Maintainer: Brandon Barnes +Build-Depends: debhelper (>= 5), libx11-dev, libxpm-dev, x11proto-core-dev +Standards-Version: 3.7.3 + +Package: xevil +Architecture: any +Depends: ${shlibs:Depends} +Description: A violent side-scrolling game for X + XEvil is a 3rd person, side-view, fast-action, + kill-them-before-they-kill-you game. Fight against either + computer-controlled enemies, or another player. + . + You sinned in life. And now you must pay. Satan pits the recently + deceased against each other to fight for rank in Hell. Your skill + determines your fate for all eternity. This contest is known as XEvil. --- xevil-2.02r2.orig/debian/xevil-serverping.6 +++ xevil-2.02r2/debian/xevil-serverping.6 @@ -0,0 +1,29 @@ +.TH serverping 6 "January 2, 2007" +.SH NAME +serverping - check the status of an XEvil server +.SH SYNOPSIS +.B serverping +[\-count num_tries] [\-timeout timeout_ms] server_name[:port] +.SH DESCRIPTION +serverping is a simple utility to give you information on an XEvil server, such as the game style, who is playing, and how well they are doing. +.SH OPTIONS +.TP +\-count num_tries +specify the number of pings to send before giving up, default=3 +.TP +\-timeout timeout_ms +specify the time in milliseconds to wait for a response before giving up, default=1000 +.TP +server_name[:port] +specify the server name or IP address, optionally with port, default port is 6066 +.SH EXAMPLES +.TP +serverping whitehouse.gov +This will give you the game status of the XEvil game running on the server at whitehouse.gov, at default port 6066. It will try 3 times, and wait 1 sec per try. At the time of this writing, whitehouse.gov is not running an XEvil server. +.TP +serverping -timeout 5000 292.43.199.64:9999 +This will give you the game status of the XEvil game running on the server at 292.43.199.64, at port 9999. It will try 3 times, and wait 5 sec per try. 292.43.199.64 is not a valid IP address. +.SH GAME AUTHOR +Steve Hardt +.SH MAN PAGE AUTHOR +Brandon Barnes --- xevil-2.02r2.orig/debian/xevil.6 +++ xevil-2.02r2/debian/xevil.6 @@ -0,0 +1,18 @@ +.TH xevil 6 "January 20, 2007" +.SH NAME +xevil - An evil game +.SH SYNOPSIS +.B xevil +[argument-list] +.SH DESCRIPTION +XEvil is a 3rd person, side-view, fast-action, kill-them-before-they-kill-you game. Fight against either computer-controlled enemies, or another player. +.PP +You sinned in life. And now you must pay. Satan pits the recently deceased against each other to fight for rank in Hell. Your skill determines your fate for all eternity. This contest is known as XEvil. +.SH Security and Stability +xevil is not stable. You can play for hours, but it may occasionally crash. Networking is especially quircky. Upstream is no longer maintaining xevil. Email sent to satan@xevil.com goes unanswered. Xevil likely has security holes. I recommend being wary in regards to playing xevil with strangers. Patches for the Debian version are welcome. +.SH MORE INFO +Type xevil -help at the command line for a list of common options. For more options and complete instructions, visit http://www.xevil.com/docs/instructions.html, or, on a debian system, /usr/share/doc/xevil/instructions/instructions.html. +.SH GAME AUTHOR +Steve Hardt +.SH MAN PAGE AUTHOR +Brandon Barnes --- xevil-2.02r2.orig/makefile +++ xevil-2.02r2/makefile @@ -42,9 +42,9 @@ $(OBJ_DIR)/ui_cmn.o $(OBJ_DIR)/l_agreement_dlg.o $(OBJ_DIR)/viewport.o -xevil: $(OBJ_DIR)/xevil $(OBJ_DIR)/xevil$(VERSION).$(PCKG_NAME).tar.Z +#xevil: $(OBJ_DIR)/xevil $(OBJ_DIR)/xevil$(VERSION).$(PCKG_NAME).tar.Z #xevil: $(OBJ_DIR)/xevil$(VERSION).$(PCKG_NAME).tar.Z -#xevil: $(OBJ_DIR)/xevil +xevil: $(OBJ_DIR)/xevil # Build the xevil executable. @@ -59,7 +59,7 @@ cd $(DEPTH)/cmn; $(MAKE) cd $(DEPTH)/x11; $(MAKE) $(CC) $(LINK_FLAGS) $(LINK_OPT) $(LIBS_DIRS) -o $(OBJ_DIR)/xevil $(ALL_OBJS) $(LIBS) - $(STRIP) $(OBJ_DIR)/xevil +# $(STRIP) $(OBJ_DIR)/xevil # Could also include serverping in the distribution $(OBJ_DIR)/xevil$(VERSION).$(PCKG_NAME).tar.Z:: --- xevil-2.02r2.orig/config.mk +++ xevil-2.02r2/config.mk @@ -83,7 +83,10 @@ #### Attempt to guesss the host architecture using the HOSTYPE and hostype # variables. Then call self with the architecture name. default: - @if [ $${HOSTTYPE-bob} != bob ] ; then \ +# FORCEHOSTTYPE is used by debian-linux + @if [ $${FORCEHOSTTYPE-bob} != bob ]; then \ + archit=$$FORCEHOSTTYPE; \ + elif [ $${HOSTTYPE-bob} != bob ] ; then \ archit=$$HOSTTYPE ; \ elif [ $${hosttype-bob} != bob ] ; then \ archit=$$hosttype ; \ @@ -252,6 +255,15 @@ OBJ_DIR=$(DEPTH)/x11/REDHAT_LINUX PCKG_NAME="redhatlinux" \ $(TARGETS) +#For debian-linux +debian-linux: + @$(MAKE) CC="g++" \ +CFLAGS="-DUSE_RANDOM -DXEVIL_KEYSET=UIlinux -DUSE_UINT_NET_LENGTH" \ +INCL_DIRS="-I/usr/X11R6/include" \ +LIBS_DIRS="-L/usr/X11R6/lib" \ +LIBS="-lXpm -lX11 -lm" \ +$(TARGETS) + # use static # Should add -DXEVIL_KEYSET=UIlinux i386-linux-old: