|
From: <ufo...@li...> - 2009-02-28 13:01:18
|
Revision: 1090
http://ufo2000.svn.sourceforge.net/ufo2000/?rev=1090&view=rev
Author: ssvb
Date: 2009-02-28 12:35:46 +0000 (Sat, 28 Feb 2009)
Log Message:
-----------
Fixes for compilation issues with the latest versions of gcc
Modified Paths:
--------------
trunk/src/LuaPlus/LuaPlusCD.h
trunk/src/server_transport.cpp
Modified: trunk/src/LuaPlus/LuaPlusCD.h
===================================================================
--- trunk/src/LuaPlus/LuaPlusCD.h 2008-07-05 12:18:34 UTC (rev 1089)
+++ trunk/src/LuaPlus/LuaPlusCD.h 2009-02-28 12:35:46 UTC (rev 1090)
@@ -24,6 +24,7 @@
#include "lauxlib.h"
}
+#include <typeinfo>
#include <string.h>
// LuaPlus Call Dispatcher
Modified: trunk/src/server_transport.cpp
===================================================================
--- trunk/src/server_transport.cpp 2008-07-05 12:18:34 UTC (rev 1089)
+++ trunk/src/server_transport.cpp 2009-02-28 12:35:46 UTC (rev 1090)
@@ -25,6 +25,7 @@
#include <vector>
#include <stdio.h>
#include <time.h>
+#include <stdlib.h>
#ifdef WIN32
#include <windows.h>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ufo...@li...> - 2009-04-18 20:55:07
|
Revision: 1101
http://ufo2000.svn.sourceforge.net/ufo2000/?rev=1101&view=rev
Author: ssvb
Date: 2009-04-18 20:55:03 +0000 (Sat, 18 Apr 2009)
Log Message:
-----------
Added missing '#include <stdlib.h>', it is needed for compilation
of game server with the latest gcc.
Modified Paths:
--------------
trunk/src/server_config.cpp
trunk/src/server_main.cpp
trunk/src/server_protocol.cpp
Modified: trunk/src/server_config.cpp
===================================================================
--- trunk/src/server_config.cpp 2009-04-18 20:53:53 UTC (rev 1100)
+++ trunk/src/server_config.cpp 2009-04-18 20:55:03 UTC (rev 1101)
@@ -24,6 +24,7 @@
#endif
#include <stdio.h>
+#include <stdlib.h>
#include <time.h>
#include <stdarg.h>
#include <nl.h>
Modified: trunk/src/server_main.cpp
===================================================================
--- trunk/src/server_main.cpp 2009-04-18 20:53:53 UTC (rev 1100)
+++ trunk/src/server_main.cpp 2009-04-18 20:55:03 UTC (rev 1101)
@@ -23,6 +23,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <nl.h>
#include <signal.h>
#include "server.h"
Modified: trunk/src/server_protocol.cpp
===================================================================
--- trunk/src/server_protocol.cpp 2009-04-18 20:53:53 UTC (rev 1100)
+++ trunk/src/server_protocol.cpp 2009-04-18 20:55:03 UTC (rev 1101)
@@ -20,6 +20,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <stdexcept>
#include "server_protocol.h"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ufo...@li...> - 2009-05-01 20:07:27
|
Revision: 1105
http://ufo2000.svn.sourceforge.net/ufo2000/?rev=1105&view=rev
Author: nachtwolf
Date: 2009-05-01 20:07:26 +0000 (Fri, 01 May 2009)
Log Message:
-----------
* Fix for bug #451 : Assert Failed 417 of multiplay.cpp.
* Added an alert for when opponent leaves the game.
* Version bump for Beta 1105
Modified Paths:
--------------
trunk/src/connect.cpp
trunk/src/multiplay.cpp
trunk/src/version.h
Modified: trunk/src/connect.cpp
===================================================================
--- trunk/src/connect.cpp 2009-04-27 06:00:48 UTC (rev 1104)
+++ trunk/src/connect.cpp 2009-05-01 20:07:26 UTC (rev 1105)
@@ -115,7 +115,7 @@
remote_win->printstr("and upgrade your UFO2000 version\n");
remote_win->printstr(tmp);
}
- net->send("QUIT");
+ net->send_quit();
net->SEND = 0;
DONE = 1;
}
@@ -130,7 +130,7 @@
remote_win->printstr("\nUnfortunately your opponent has an\n");
remote_win->printstr("outdated UFO2000 version and you will be\n");
remote_win->printstr("unable to play until he upgrades\n");
- net->send("QUIT");
+ net->send_quit();
net->SEND = 0;
}
DONE = 1;
@@ -155,7 +155,7 @@
remote_win->redraw();
break;
case KEY_ESC:
- net->send("QUIT");
+ net->send_quit();
net->SEND = 0;
DONE = 1;
break;
@@ -208,9 +208,9 @@
{
lua_message( "Enter: Connect::do_planner" );
MODE = PLANNER;
-
int mouse_leftr = 1, mouse_rightr = 1;
int DONE = 0;
+ int REMOTE_LEFT = 0;
//HOST = 0;
FINISH_PLANNER = 0;
@@ -231,7 +231,7 @@
Map *map = new Map(mapdata);
BITMAP *map2d = map->create_bitmap_of_map(0);
int map2d_x = (640 - map2d->w) / 2;
-
+
if (HOST) {
target_uints[1] = &remote;
target_uints[0] = &local;
@@ -276,16 +276,48 @@
}
net->send_terrain_crc32("", 0);
#define map g_map
-
+
// Wait until a complete list of remote terrains is received
- while (g_net_allowed_terrains.find("") == g_net_allowed_terrains.end()) {
+ while ((g_net_allowed_terrains.find("") == g_net_allowed_terrains.end()) && (!REMOTE_LEFT)) {
net->check();
rest(1);
+
+ process_keyswitch();
+
+ if (keypressed()) {
+ CHANGE = 1;
+
+ int scancode;
+ int keycode = ureadkey(&scancode);
+
+ switch (scancode) {
+ case KEY_ESC:
+ if (askmenu( _("EXIT MISSION-PLANNER") )) {
+ net->send_quit();
+ net->SEND = 0;
+ REMOTE_LEFT = 1;
+ }
+ break;
+ default:
+ if (g_console->process_keyboard_input(keycode, scancode))
+ net->send_message((char *)g_console->get_text());
+ }
+ }
}
-
// Remove end marker
g_net_allowed_terrains.erase("");
+ if (REMOTE_LEFT) {
+ delete map;
+ SCREEN2H = old_SCREEN2H;
+ destroy_bitmap(screen2);
+ screen2 = create_bitmap(SCREEN2W, SCREEN2H); clear(screen2);
+ clear(screen);
+ g_console->resize(SCREEN_W, SCREEN_H - SCREEN2H);
+ g_console->set_full_redraw();
+ return 0;
+ }
+
if (g_net_allowed_terrains.size() == 0) {
alert( "", _("Remote player does not have any of your maps"), "",
_("OK"), NULL, 0, 0);
@@ -341,7 +373,7 @@
g_console->printf( COLOR_SYS_INFO1, _("To edit a soldier, CTRL-click on his name.") );
g_console->printf( COLOR_SYS_INFO1, _("Left-click to place a soldier on the map, right-click to remove him.") );
g_console->printf( COLOR_SYS_PROMPT, _("When finished, click SEND, then START. Press ESC to quit, F1 for help.") );
-
+
while (!DONE) {
rest(1); // Don't eat all CPU resources
Modified: trunk/src/multiplay.cpp
===================================================================
--- trunk/src/multiplay.cpp 2009-04-27 06:00:48 UTC (rev 1104)
+++ trunk/src/multiplay.cpp 2009-05-01 20:07:26 UTC (rev 1105)
@@ -452,8 +452,11 @@
int Net::recv_quit()
{ // "QUIT"
+ //Is this really an error ??
error("Remote exit from game");
- return 1;
+ alert( "", _("Your opponent left the game"), "",
+ _("OK"), NULL, 0, 0);
+ return 1;
}
extern void restartgame();
Modified: trunk/src/version.h
===================================================================
--- trunk/src/version.h 2009-04-27 06:00:48 UTC (rev 1104)
+++ trunk/src/version.h 2009-05-01 20:07:26 UTC (rev 1105)
@@ -23,7 +23,7 @@
#define UFO_VERSION_TAG "beta9"
#define UFO_VERSION_STRING "0.9"
-#define UFO_REVISION_NUMBER 1103
+#define UFO_REVISION_NUMBER 1105
#ifndef UFO_SVNVERSION
#define UFO_SVNVERSION "unknown"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ufo...@li...> - 2010-05-07 19:31:03
|
Revision: 1115
http://ufo2000.svn.sourceforge.net/ufo2000/?rev=1115&view=rev
Author: ssvb
Date: 2010-05-07 19:30:56 +0000 (Fri, 07 May 2010)
Log Message:
-----------
Put all server related code under ENABLE_UFO2K_SERVER define
From: Siarhei Siamashka <sia...@gm...>
Modified Paths:
--------------
trunk/src/server.h
trunk/src/server_game.h
trunk/src/server_protocol.h
Modified: trunk/src/server.h
===================================================================
--- trunk/src/server.h 2010-04-15 09:00:12 UTC (rev 1114)
+++ trunk/src/server.h 2010-05-07 19:30:56 UTC (rev 1115)
@@ -26,13 +26,6 @@
#define PACKET_SIZE_LIMIT 65536
#endif
-inline double get_time_diff(const NLtime &x, const NLtime &y)
-{
- return (double)(y.seconds - x.seconds) * 1000.0 + (double)(y.mseconds - x.mseconds);
-}
-
-class ServerDispatch;
-
//! Encode std::map<std::string, std::string> into a single string
int encode_stringmap(const std::map<std::string, std::string> &info, std::string &buffer);
//! Decode std::map<std::string, std::string> from a string
@@ -63,6 +56,15 @@
int wait_packet(NLuint &id, std::string &buffer);
};
+#ifdef ENABLE_UFO2K_SERVER
+
+inline double get_time_diff(const NLtime &x, const NLtime &y)
+{
+ return (double)(y.seconds - x.seconds) * 1000.0 + (double)(y.mseconds - x.mseconds);
+}
+
+class ServerDispatch;
+
/**
* Server side client-server connection
*
@@ -133,3 +135,5 @@
};
#endif
+
+#endif
Modified: trunk/src/server_game.h
===================================================================
--- trunk/src/server_game.h 2010-04-15 09:00:12 UTC (rev 1114)
+++ trunk/src/server_game.h 2010-05-07 19:30:56 UTC (rev 1115)
@@ -24,6 +24,8 @@
#include "server_protocol.h"
+#ifdef ENABLE_UFO2K_SERVER
+
class Server_Game_UFO
{
public:
@@ -51,3 +53,5 @@
};
#endif
+
+#endif
Modified: trunk/src/server_protocol.h
===================================================================
--- trunk/src/server_protocol.h 2010-04-15 09:00:12 UTC (rev 1114)
+++ trunk/src/server_protocol.h 2010-05-07 19:30:56 UTC (rev 1115)
@@ -58,6 +58,8 @@
#define SRV_ADVANCED_PACKET_MASK 0x80000000
+#ifdef ENABLE_UFO2K_SERVER
+
class Server_Game_UFO;
class ServerClientUfo: public ServerClient
@@ -94,6 +96,8 @@
int validate_user(const std::string &username, const std::string &password);
};
+#endif
+
class ClientServerUfo: public ClientServer
{
public:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ufo...@li...> - 2010-05-09 18:55:02
|
Revision: 1119
http://ufo2000.svn.sourceforge.net/ufo2000/?rev=1119&view=rev
Author: ssvb
Date: 2010-05-09 18:54:56 +0000 (Sun, 09 May 2010)
Log Message:
-----------
Fixed compilation issues when using more recent versions of mingw
An old and hackish 'usleep' define in 'stdafx.h' started to clash with
mingw headers for the recent versions of mingw (because now mingw
provides 'usleep' function itself). The solution was to just switch
to the use of allegro-specific 'rest' function which provides the same
functionality.
It's a temporary solution anyway, because any occurences of
usleep/rest functions should be eliminated completely in order to
reduce power consumption. Low power consumption is important
for battery powered devices (laptops and smartphones).
Author: Siarhei Siamashka <sia...@gm...>
Modified Paths:
--------------
trunk/src/mainmenu.cpp
trunk/src/music.cpp
trunk/src/server_gui.cpp
trunk/src/stdafx.h
Modified: trunk/src/mainmenu.cpp
===================================================================
--- trunk/src/mainmenu.cpp 2010-05-07 19:57:43 UTC (rev 1118)
+++ trunk/src/mainmenu.cpp 2010-05-09 18:54:56 UTC (rev 1119)
@@ -155,7 +155,7 @@
break;
case MSG_IDLE:
- usleep(5000);
+ rest(5);
break;
default:
Modified: trunk/src/music.cpp
===================================================================
--- trunk/src/music.cpp 2010-05-07 19:57:43 UTC (rev 1118)
+++ trunk/src/music.cpp 2010-05-09 18:54:56 UTC (rev 1119)
@@ -55,7 +55,7 @@
}
}
nlMutexUnlock(&mutex);
- usleep(10000);
+ rest(10);
}
nlMutexDestroy(&mutex);
return NULL;
Modified: trunk/src/server_gui.cpp
===================================================================
--- trunk/src/server_gui.cpp 2010-05-07 19:57:43 UTC (rev 1118)
+++ trunk/src/server_gui.cpp 2010-05-09 18:54:56 UTC (rev 1119)
@@ -730,7 +730,7 @@
}
}
// Do not load cpu so heavy
- usleep(10000);
+ rest(10);
}
show_mouse(NULL);
Modified: trunk/src/stdafx.h
===================================================================
--- trunk/src/stdafx.h 2010-05-07 19:57:43 UTC (rev 1118)
+++ trunk/src/stdafx.h 2010-05-09 18:54:56 UTC (rev 1119)
@@ -98,10 +98,6 @@
#include "LuaPlus/LuaPlusCD.h"
-#ifdef WIN32
-#define usleep(t) Sleep((t + 999) / 1000)
-#endif
-
/**
* Standard game errors are coded with these constants.
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ufo...@li...> - 2010-05-22 17:52:36
|
Revision: 1133
http://ufo2000.svn.sourceforge.net/ufo2000/?rev=1133&view=rev
Author: ssvb
Date: 2010-05-22 17:52:30 +0000 (Sat, 22 May 2010)
Log Message:
-----------
Rename function 'Connect::do_chat' -> 'Connect::do_version_check'
Because that is what it is actually doing.
From: Siarhei Siamashka <sia...@gm...>
Modified Paths:
--------------
trunk/src/connect.cpp
trunk/src/connect.h
trunk/src/multiplay.cpp
Modified: trunk/src/connect.cpp
===================================================================
--- trunk/src/connect.cpp 2010-05-19 00:18:16 UTC (rev 1132)
+++ trunk/src/connect.cpp 2010-05-22 17:52:30 UTC (rev 1133)
@@ -48,7 +48,7 @@
* @todo remove all the unneeded stuff here, this function does not need
* displaying any graphics at all
*/
-int Connect::do_chat()
+int Connect::do_version_check()
{
Wind *local_win = NULL, *remote_win = NULL, *info_win = NULL;
Modified: trunk/src/connect.h
===================================================================
--- trunk/src/connect.h 2010-05-19 00:18:16 UTC (rev 1132)
+++ trunk/src/connect.h 2010-05-22 17:52:30 UTC (rev 1133)
@@ -24,7 +24,7 @@
class Connect
{
public:
- int do_chat();
+ int do_version_check();
void reset_uds();
void swap_uds();
int do_planner(int F10ALLOWED, int map_change_allowed = 1);
Modified: trunk/src/multiplay.cpp
===================================================================
--- trunk/src/multiplay.cpp 2010-05-19 00:18:16 UTC (rev 1132)
+++ trunk/src/multiplay.cpp 2010-05-22 17:52:30 UTC (rev 1133)
@@ -137,7 +137,7 @@
alert(" ", _(" GAME START "), " ", _(" OK "), NULL, 1, 0);
inithotseatgame();
} else {
- if (!connect->do_chat() || !connect->do_planner(0)) {
+ if (!connect->do_version_check() || !connect->do_planner(0)) {
close();
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ufo...@li...> - 2010-05-22 19:18:01
|
Revision: 1134
http://ufo2000.svn.sourceforge.net/ufo2000/?rev=1134&view=rev
Author: ssvb
Date: 2010-05-22 19:17:55 +0000 (Sat, 22 May 2010)
Log Message:
-----------
Function 'show_help' moved to text.cpp for future reuse.
From: Siarhei Siamashka <sia...@gm...>
Modified Paths:
--------------
trunk/src/server_gui.cpp
trunk/src/text.cpp
trunk/src/text.h
Modified: trunk/src/server_gui.cpp
===================================================================
--- trunk/src/server_gui.cpp 2010-05-22 17:52:30 UTC (rev 1133)
+++ trunk/src/server_gui.cpp 2010-05-22 19:17:55 UTC (rev 1134)
@@ -307,26 +307,6 @@
bool set_autologin_on = false;
-static void show_help(const char *text)
-{
- int w = SCREEN_W * 3 / 4;
- int h = SCREEN_H * 3 / 4;
- DIALOG help_dialog[] = {
- //(dialog proc) (x) (y) (w) (h) (fg)(bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
- { d_agup_shadow_box_proc, 0, 0, w, h, 0, 1, 0, 0, 0, 0, NULL, NULL, NULL },
- { d_agup_textbox_proc, 10, 10, w - 20, h - 40, 0, 1, 0, 0, 0, 0, (void *)text, NULL, NULL },
- { d_agup_button_proc, w - 70, h - 25, 60, 18, 0, 1, 13, D_EXIT, 0, 0, (void *)_("OK"), NULL, NULL },
- { d_yield_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL},
- { NULL }
- };
- FONT *old_font = font;
- font = large;
- centre_dialog(help_dialog);
- set_dialog_color(help_dialog, COLOR_BLACK1, COLOR_WHITE);
- popup_dialog(help_dialog, 2);
- font = old_font;
-}
-
static int help_button_proc(
int msg, DIALOG *d, int c)
{
Modified: trunk/src/text.cpp
===================================================================
--- trunk/src/text.cpp 2010-05-22 17:52:30 UTC (rev 1133)
+++ trunk/src/text.cpp 2010-05-22 19:17:55 UTC (rev 1134)
@@ -1026,3 +1026,26 @@
}
END_OF_FUNCTION(help);
+/**
+ * Show a large dialog with formatted text. It is useful for showing help
+ * pages with long descriptions of something.
+ */
+void show_help(const char *text)
+{
+ int w = SCREEN_W * 3 / 4;
+ int h = SCREEN_H * 3 / 4;
+ DIALOG help_dialog[] = {
+ //(dialog proc) (x) (y) (w) (h) (fg)(bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
+ { d_agup_shadow_box_proc, 0, 0, w, h, 0, 1, 0, 0, 0, 0, NULL, NULL, NULL },
+ { d_agup_textbox_proc, 10, 10, w - 20, h - 40, 0, 1, 0, 0, 0, 0, (void *)text, NULL, NULL },
+ { d_agup_button_proc, w - 70, h - 25, 60, 18, 0, 1, 13, D_EXIT, 0, 0, (void *)_("OK"), NULL, NULL },
+ { d_yield_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL},
+ { NULL }
+ };
+ FONT *old_font = font;
+ font = large;
+ centre_dialog(help_dialog);
+ set_dialog_color(help_dialog, COLOR_BLACK1, COLOR_WHITE);
+ popup_dialog(help_dialog, 2);
+ font = old_font;
+}
Modified: trunk/src/text.h
===================================================================
--- trunk/src/text.h 2010-05-22 17:52:30 UTC (rev 1133)
+++ trunk/src/text.h 2010-05-22 19:17:55 UTC (rev 1134)
@@ -74,5 +74,8 @@
//! Simple help, using alert3().
void help( const int helppage );
+//! Show a large dialog with formatted text.
+void show_help(const char *text);
+
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ufo...@li...> - 2010-05-22 21:38:09
|
Revision: 1135
http://ufo2000.svn.sourceforge.net/ufo2000/?rev=1135&view=rev
Author: ssvb
Date: 2010-05-22 21:38:03 +0000 (Sat, 22 May 2010)
Log Message:
-----------
Added C++ variant of lua 'string.format' (a safe sprintf replacement)
New function 'string_format' function works just like 'sprintf', but
uses std::string as a destination.
From: Siarhei Siamashka <sia...@gm...>
Modified Paths:
--------------
trunk/src/text.cpp
trunk/src/text.h
Modified: trunk/src/text.cpp
===================================================================
--- trunk/src/text.cpp 2010-05-22 19:17:55 UTC (rev 1134)
+++ trunk/src/text.cpp 2010-05-22 21:38:03 UTC (rev 1135)
@@ -1049,3 +1049,29 @@
popup_dialog(help_dialog, 2);
font = old_font;
}
+
+std::string string_vformat(const char *fmt, va_list arglist)
+{
+ int bufsize = 1024;
+ char *buf = new char[bufsize];
+ while (true) {
+ int result = vsnprintf(buf, bufsize, fmt, arglist);
+ if (result >= 0 && result < bufsize)
+ break;
+ delete [] buf;
+ bufsize *= 2;
+ buf = new char[bufsize];
+ }
+ std::string text = buf;
+ delete [] buf;
+ return text;
+}
+
+std::string string_format(const char *fmt, ...)
+{
+ va_list arglist;
+ va_start(arglist, fmt);
+ std::string text = string_vformat(fmt, arglist);
+ va_end(arglist);
+ return text;
+}
Modified: trunk/src/text.h
===================================================================
--- trunk/src/text.h 2010-05-22 19:17:55 UTC (rev 1134)
+++ trunk/src/text.h 2010-05-22 21:38:03 UTC (rev 1135)
@@ -77,5 +77,12 @@
//! Show a large dialog with formatted text.
void show_help(const char *text);
+//! A C++ variant of lua 'string.format' (a safe sprintf replacement)
+#if defined(__GNUC__)
+__attribute__((__format__(__printf__,1,2)))
#endif
+std::string string_format(const char *fmt, ...);
+std::string string_vformat(const char *fmt, va_list arglist);
+#endif
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ufo...@li...> - 2010-05-23 17:22:24
|
Revision: 1139
http://ufo2000.svn.sourceforge.net/ufo2000/?rev=1139&view=rev
Author: ssvb
Date: 2010-05-23 17:22:18 +0000 (Sun, 23 May 2010)
Log Message:
-----------
Fixed a bunch of string format related issues reported as gcc warnings
From: Siarhei Siamashka <sia...@gm...>
Modified Paths:
--------------
trunk/src/editor.cpp
trunk/src/main.cpp
trunk/src/multiplay.cpp
trunk/src/scenario.cpp
trunk/src/soldier.cpp
trunk/src/units.cpp
Modified: trunk/src/editor.cpp
===================================================================
--- trunk/src/editor.cpp 2010-05-23 16:57:26 UTC (rev 1138)
+++ trunk/src/editor.cpp 2010-05-23 17:22:18 UTC (rev 1139)
@@ -382,7 +382,7 @@
int x2 = 236;
sprintf(str1, "%s: %4d", _("Equipment cost"), man->calc_full_ammunition_cost() );
int w1 = text_length(g_small_font, str1); // right-justify string
- textprintf(screen2, g_small_font, x2-w1, 20, COLOR_GRAY02, str1);
+ textprintf(screen2, g_small_font, x2-w1, 20, COLOR_GRAY02, "%s", str1);
draw_alpha_sprite(screen2, mouser, mouse_x, mouse_y);
blit(screen2, screen, 0, 0, 0, 0, screen2->w, screen2->h);
Modified: trunk/src/main.cpp
===================================================================
--- trunk/src/main.cpp 2010-05-23 16:57:26 UTC (rev 1138)
+++ trunk/src/main.cpp 2010-05-23 17:22:18 UTC (rev 1139)
@@ -1909,8 +1909,8 @@
//textprintf(newscr, large, x1, y1, COLOR_GREEN, _("Your Platoon") );
//textprintf(newscr, large, x2, y1, COLOR_GREEN, _("Remote Platoon") );
}
- textprintf(newscr, large, x1, y1, COLOR_GREEN, player1 );
- textprintf(newscr, large, x2, y1, COLOR_GREEN, player2 );
+ textprintf(newscr, large, x1, y1, COLOR_GREEN, "%s", player1 );
+ textprintf(newscr, large, x2, y1, COLOR_GREEN, "%s", player2 );
strcpy(txt, _("Total Kills:") );
textprintf(newscr, g_small_font, x1+ 0, y2+0*h, COLOR_RED03, "%s", txt );
@@ -2124,7 +2124,7 @@
chk = -chk; // Error codes are negative.
if(FLAGS & F_ENDTURNSND)
soundSystem::getInstance()->play(SS_BUTTON_PUSH_2);
- g_console->printf(GameErrorColour[chk], GameErrorMessage[chk]);
+ g_console->printf(GameErrorColour[chk], "%s", GameErrorMessage[chk]);
}
/**
@@ -2629,7 +2629,7 @@
} else {
sprintf(buf, "%s", _("You: Draw offer recalled"));
}
- g_console->printf(COLOR_SYS_PROMPT, buf);
+ g_console->printf(COLOR_SYS_PROMPT, "%s", buf);
battle_report("# %s\n", buf);
}
}
Modified: trunk/src/multiplay.cpp
===================================================================
--- trunk/src/multiplay.cpp 2010-05-23 16:57:26 UTC (rev 1138)
+++ trunk/src/multiplay.cpp 2010-05-23 17:22:18 UTC (rev 1139)
@@ -263,7 +263,7 @@
if (!packet.empty()) {
queue->put(packet);
if (FLAGS & F_RAWMESSAGES) {
- g_console->printf( _("put:[%d]"), packet.size());
+ g_console->printf( _("put:[%d]"), (int)packet.size());
g_console->printf("%s", packet.c_str());
}
}
@@ -274,7 +274,7 @@
if (!queue->get(packet)) return;
if (FLAGS & F_RAWMESSAGES) {
- g_console->printf( _("get:[%d]"), packet.size());
+ g_console->printf( _("get:[%d]"), (int)packet.size());
g_console->printf("%s", packet.c_str());
}
@@ -1328,7 +1328,7 @@
// special end of terrain list marker received (empty terrain name)
g_console->printf("\n");
g_console->printf( _("Remote player has the following %d maps that can be used for network game:\n"),
- g_net_allowed_terrains.size());
+ (int)g_net_allowed_terrains.size());
std::string tlist = "";
@@ -1637,7 +1637,7 @@
} else {
sprintf(buf, "%s", _("Opponent: Draw offer recalled"));
}
- g_console->printf(COLOR_SYS_PROMPT, buf);
+ g_console->printf(COLOR_SYS_PROMPT, "%s", buf);
battle_report("# %s\n", buf);
return 0;
}
Modified: trunk/src/scenario.cpp
===================================================================
--- trunk/src/scenario.cpp 2010-05-23 16:57:26 UTC (rev 1138)
+++ trunk/src/scenario.cpp 2010-05-23 17:22:18 UTC (rev 1139)
@@ -822,7 +822,7 @@
platoon->findnum(i)->place(P_MAP)->get_items_list(items);
if (items.size() > 0) {
- g_console->printf(COLOR_RED04, _("Items on the ground aren't allowed (you have: %d, including unselected soldiers)."), items.size());
+ g_console->printf(COLOR_RED04, _("Items on the ground aren't allowed (you have: %d, including unselected soldiers)."), (int)items.size());
return false;
}
}
Modified: trunk/src/soldier.cpp
===================================================================
--- trunk/src/soldier.cpp 2010-05-23 16:57:26 UTC (rev 1138)
+++ trunk/src/soldier.cpp 2010-05-23 17:22:18 UTC (rev 1139)
@@ -1111,7 +1111,7 @@
if((havetime(walk_time + time, 0) != OK) && (havetime(time, 0) == OK)) {
if(error != "")
- g_console->printf(COLOR_SYS_INFO1, error.c_str());
+ g_console->printf(COLOR_SYS_INFO1, "%s", error.c_str());
return havetime(walk_time + time, 0);
} else {
return havetime(walk_time, use_energy);
Modified: trunk/src/units.cpp
===================================================================
--- trunk/src/units.cpp 2010-05-23 16:57:26 UTC (rev 1138)
+++ trunk/src/units.cpp 2010-05-23 17:22:18 UTC (rev 1139)
@@ -314,13 +314,13 @@
textout_centre(screen2, font, _("Player 1"), x0, SCREEN2H - 285, xcom1_color(CAPTION));
for (i = 0; i < 8; i++)
- textprintf(screen2, font, x0 - x1 + 5, SCREEN2H - 270 + i * 9, xcom1_color(COMMENT), scenario->briefing_left[scenario->type][i]);
+ textprintf(screen2, font, x0 - x1 + 5, SCREEN2H - 270 + i * 9, xcom1_color(COMMENT), "%s", scenario->briefing_left[scenario->type][i]);
if (pos == POS_LEFT)
rect(screen2, x0 - x1 + 3, SCREEN2H - 272, x0 + x1 - 3, SCREEN2H - 198, xcom1_color(LOCAL_COLOR));
textout_centre(screen2, font, _("Player 2"), x0, SCREEN2H - 185, xcom1_color(CAPTION));
for (i = 0; i < 8; i++)
- textprintf(screen2, font, x0 - x1 + 5, SCREEN2H - 170 + i * 9, xcom1_color(COMMENT), scenario->briefing_right[scenario->type][i]);
+ textprintf(screen2, font, x0 - x1 + 5, SCREEN2H - 170 + i * 9, xcom1_color(COMMENT), "%s", scenario->briefing_right[scenario->type][i]);
if (pos == POS_RIGHT)
rect(screen2, x0 - x1 + 3, SCREEN2H - 172, x0 + x1 - 3, SCREEN2H - 98, xcom1_color(LOCAL_COLOR));
@@ -333,14 +333,14 @@
break;
case OPT_NUMBER:
- textprintf(screen2, font, x0 - x1 + 5, SCREEN2H - 70 + i * 9, xcom1_color(COMMENT), scenario->options[scenario->type][i]->caption);
+ textprintf(screen2, font, x0 - x1 + 5, SCREEN2H - 70 + i * 9, xcom1_color(COMMENT), "%s", scenario->options[scenario->type][i]->caption);
textout_centre(screen2, font, "<", x0 + 150, SCREEN2H - 70 + i * 9, xcom1_color(BUTTON));
textprintf_centre(screen2, font, x0 + 170, SCREEN2H - 70 + i * 9, xcom1_color(SELECTED), "%d", scenario->options[scenario->type][i]->value);
textout_centre(screen2, font, ">", x0 + 190, SCREEN2H - 70 + i * 9, xcom1_color(BUTTON));
break;
case OPT_SWITCH:
- textprintf(screen2, font, x0 - x1 + 5, SCREEN2H - 70 + i * 9, scenario->options[scenario->type][i]->value ? xcom1_color(SWITCH_ON) : xcom1_color(SWITCH_OFF), scenario->options[scenario->type][i]->value ? scenario->options[scenario->type][i]->caption_on : scenario->options[scenario->type][i]->caption_off);
+ textprintf(screen2, font, x0 - x1 + 5, SCREEN2H - 70 + i * 9, scenario->options[scenario->type][i]->value ? xcom1_color(SWITCH_ON) : xcom1_color(SWITCH_OFF), "%s", scenario->options[scenario->type][i]->value ? scenario->options[scenario->type][i]->caption_on : scenario->options[scenario->type][i]->caption_off);
break;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ufo...@li...> - 2010-05-23 23:50:24
|
Revision: 1140
http://ufo2000.svn.sourceforge.net/ufo2000/?rev=1140&view=rev
Author: ssvb
Date: 2010-05-23 23:50:18 +0000 (Sun, 23 May 2010)
Log Message:
-----------
Fixed soldier name buffer overflow bug (issue #554).
This fix resolves issue #0000554 ('Assert failed at line 195 of units.cpp').
Replaced magic numbers 22 and 26 all over the source code to constants
MAN_NAME_LEN and MAN_NAME_BUFSIZE. Buffer size increased to actually
be large enough to fit MAN_NAME_LEN characters (one UTF-8 character can
take up to 6 bytes). Version bumped because the changes break compatibility
with older releases.
From: Siarhei Siamashka <sia...@gm...>
Modified Paths:
--------------
trunk/src/editor.cpp
trunk/src/global.h
trunk/src/soldier.cpp
trunk/src/soldier.h
trunk/src/stats.h
trunk/src/units.cpp
trunk/src/units.h
trunk/src/version.h
Modified: trunk/src/editor.cpp
===================================================================
--- trunk/src/editor.cpp 2010-05-23 17:22:18 UTC (rev 1139)
+++ trunk/src/editor.cpp 2010-05-23 23:50:18 UTC (rev 1140)
@@ -855,7 +855,7 @@
{ d_agup_shadow_box_proc, DX, DY, D_WIDTH, D_HEIGHT, FG, BG, 0, 0, 0, 0, NULL, NULL, NULL},
{ d_agup_button_proc, DX + 200, DY + SSY + SH*13 + 4, 100, 20, FG, BG, 0, D_EXIT, 0, 0, (void *)_("OK"), NULL, NULL},
{ d_agup_rtext_proc, DX + STX, DY + SSY - SH*1, STW, 16, FG, BG, 0, 0, 0, 0, (void *)_("Name:"), NULL, NULL},
- { d_agup_edit_proc, DX + SSX, DY + SSY - SH*1 - 4, 23*8, 16, FG, BG, 0, 0, 22, 0, NULL, NULL, NULL},
+ { d_agup_edit_proc, DX + SSX, DY + SSY - SH*1 - 4, 23*8, 16, FG, BG, 0, 0, MAN_NAME_LEN, 0, NULL, NULL, NULL},
{ d_agup_text_proc, DX + 100, DY + SSY + SH*12 + 2, 100, 16, FG, BG, 0, 0, 0, 0, (void *)points_str, NULL, NULL},
{ d_agup_rtext_proc, DX + STX, DY + SSY + SH*0 + 1, STW, 16 + 4, FG, BG, 0, 0, 0, 0, (void *)_("Race:"), NULL, NULL},
Modified: trunk/src/global.h
===================================================================
--- trunk/src/global.h 2010-05-23 17:22:18 UTC (rev 1139)
+++ trunk/src/global.h 2010-05-23 23:50:18 UTC (rev 1140)
@@ -194,11 +194,15 @@
uint8 mapdata[36]; //!< The actual map data - refers to the number at the end of map name; i.e. urban12 would be number
};
+// Name length limit in characters
+#define MAN_NAME_LEN 22
+// Name buffer size (each character can take up to 6 bytes in UTF-8)
+#define MAN_NAME_BUFSIZE (MAN_NAME_LEN * 6 + 1)
+
#pragma pack(1)
struct MANDATA
{
-#define MAN_NAME_LEN 22
- char Name[26]; //!< There are actually 26 bytes allocated for this, but only the first 23 are used. The names can be up to 22 bytes.
+ char Name[MAN_NAME_BUFSIZE];
unsigned char TimeUnits; //!< TU each turn for actions
unsigned char Health; //!< Hitpoints: when down to 0, soldier dies
unsigned char Stamina; //!< Actions like walking consume TU as well as energy
Modified: trunk/src/soldier.cpp
===================================================================
--- trunk/src/soldier.cpp 2010-05-23 17:22:18 UTC (rev 1139)
+++ trunk/src/soldier.cpp 2010-05-23 23:50:18 UTC (rev 1140)
@@ -403,7 +403,7 @@
bool Soldier::set_name(const char *newname)
{
- if (strlen(newname) + 1 > sizeof(ud.Name)) return false;
+ if (ustrlen(newname) > MAN_NAME_LEN) return false;
strcpy(ud.Name, newname);
strcpy(md.Name, newname);
return true;
Modified: trunk/src/soldier.h
===================================================================
--- trunk/src/soldier.h 2010-05-23 17:22:18 UTC (rev 1139)
+++ trunk/src/soldier.h 2010-05-23 23:50:18 UTC (rev 1140)
@@ -63,7 +63,7 @@
unsigned char LArmWound;
unsigned char RLegWound;
unsigned char LLegWound;
- char Name[26]; //!< The unit name!!
+ char Name[MAN_NAME_BUFSIZE]; //!< The unit name!!
};
#define P_SHL_RIGHT 0
Modified: trunk/src/stats.h
===================================================================
--- trunk/src/stats.h 2010-05-23 17:22:18 UTC (rev 1139)
+++ trunk/src/stats.h 2010-05-23 23:50:18 UTC (rev 1140)
@@ -34,7 +34,7 @@
DECLARE_PERSISTENCE(StatEntry);
private:
int SID; //!< The soldier's ID
- char name[26]; //!< The name of the soldier
+ char name[MAN_NAME_BUFSIZE]; //!< The name of the soldier
int kills; //!< The number of soldiers he's killed
int dead; //!< Is he dead?
int damage_inflicted; //!< How much damage did he inflict?
Modified: trunk/src/units.cpp
===================================================================
--- trunk/src/units.cpp 2010-05-23 17:22:18 UTC (rev 1139)
+++ trunk/src/units.cpp 2010-05-23 23:50:18 UTC (rev 1140)
@@ -137,10 +137,14 @@
int Units::add(int num, const char *nm, int ct)
{
- if (num < 0 || num >= SQUAD_LIMIT)
+ if (num < 0 || num >= SQUAD_LIMIT) {
+ ASSERT(false);
return 0;
- if (strlen(nm) >= 25)
+ }
+ if (ustrlen(nm) > MAN_NAME_LEN) {
+ ASSERT(false);
return 0;
+ }
size = num;
strcpy(name[size], nm);
cost[size] = ct;
Modified: trunk/src/units.h
===================================================================
--- trunk/src/units.h 2010-05-23 17:22:18 UTC (rev 1139)
+++ trunk/src/units.h 2010-05-23 23:50:18 UTC (rev 1140)
@@ -36,7 +36,7 @@
friend class Connect;
private:
int size;
- char name[SQUAD_LIMIT][26];
+ char name[SQUAD_LIMIT][MAN_NAME_BUFSIZE];
int cost[SQUAD_LIMIT];
int lev[SQUAD_LIMIT], col[SQUAD_LIMIT], row[SQUAD_LIMIT];
int selected; //!< number of the soldier currently selected for editing
Modified: trunk/src/version.h
===================================================================
--- trunk/src/version.h 2010-05-23 17:22:18 UTC (rev 1139)
+++ trunk/src/version.h 2010-05-23 23:50:18 UTC (rev 1140)
@@ -23,7 +23,7 @@
#define UFO_VERSION_TAG "beta9"
#define UFO_VERSION_STRING "0.9"
-#define UFO_REVISION_NUMBER 1129
+#define UFO_REVISION_NUMBER 1140
#ifndef UFO_SVNVERSION
#define UFO_SVNVERSION "unknown"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ufo...@li...> - 2010-06-20 22:35:45
|
Revision: 1151
http://ufo2000.svn.sourceforge.net/ufo2000/?rev=1151&view=rev
Author: ssvb
Date: 2010-06-20 22:35:38 +0000 (Sun, 20 Jun 2010)
Log Message:
-----------
Added support for setting background picture for ConsoleWindow class
From: Siarhei Siamashka <sia...@gm...>
Modified Paths:
--------------
trunk/src/wind.cpp
trunk/src/wind.h
Modified: trunk/src/wind.cpp
===================================================================
--- trunk/src/wind.cpp 2010-06-19 23:32:17 UTC (rev 1150)
+++ trunk/src/wind.cpp 2010-06-20 22:35:38 UTC (rev 1151)
@@ -105,17 +105,23 @@
return false;
}
-ConsoleWindow::ConsoleWindow(int width, int height, FONT *font)
+ConsoleWindow::ConsoleWindow(int width, int height, BITMAP *bg, FONT *font)
{
m_width = width;
m_height = height;
m_font = font;
+ m_background_bmp = NULL;
+ if (bg) {
+ m_background_bmp = create_bitmap(bg->w, bg->h);
+ blit(bg, m_background_bmp, 0, 0, 0, 0, bg->w, bg->h);
+ }
m_status_line = new ConsoleStatusLine(width, font, COLOR_WHITE);
m_need_redraw = true;
}
ConsoleWindow::~ConsoleWindow()
{
+ destroy_bitmap(m_background_bmp);
delete m_status_line;
}
@@ -125,7 +131,15 @@
acquire_bitmap(bmp);
BITMAP *temp_bmp = create_bitmap(m_width, m_height);
- clear_to_color(temp_bmp, COLOR_BLACK1);
+ if (m_background_bmp) {
+ int x, y;
+ for (y = 0; y < m_height; y += m_background_bmp->h)
+ for (x = 0; x < m_width; x += m_background_bmp->w)
+ blit(m_background_bmp, temp_bmp, 0, 0, x, y,
+ m_background_bmp->w, m_background_bmp->h);
+ } else {
+ clear_to_color(temp_bmp, COLOR_BLACK1);
+ }
int lines_to_show = (m_height - m_status_line->get_height()) / text_height(m_font);
for (int i = m_lines_text.size() - 1, j = 1; i >= 0 && j <= lines_to_show; i--, j++) {
text_mode(-1);
Modified: trunk/src/wind.h
===================================================================
--- trunk/src/wind.h 2010-06-19 23:32:17 UTC (rev 1150)
+++ trunk/src/wind.h 2010-06-20 22:35:38 UTC (rev 1151)
@@ -105,9 +105,11 @@
std::vector<int> m_lines_color;
ConsoleStatusLine *m_status_line;
FONT *m_font;
+ BITMAP *m_background_bmp;
bool m_need_redraw;
public:
- ConsoleWindow(int width, int height, FONT *font = g_console_font);
+ ConsoleWindow(int width, int height, BITMAP *bg = NULL,
+ FONT *font = g_console_font);
virtual ~ConsoleWindow();
virtual void redraw_full(BITMAP *bmp, int x, int y);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ufo...@li...> - 2010-06-20 23:00:36
|
Revision: 1152
http://ufo2000.svn.sourceforge.net/ufo2000/?rev=1152&view=rev
Author: ssvb
Date: 2010-06-20 23:00:30 +0000 (Sun, 20 Jun 2010)
Log Message:
-----------
Added possibility to hide empty text entry line for chat windows
This can save some of the precious screen space when working
with low resolution (640x480 is the minimally supported screen
resolution at the moment). Also it may be handly when user input
is not needed (a window with some informational text messages).
From: Siarhei Siamashka <sia...@gm...>
Modified Paths:
--------------
trunk/src/wind.cpp
trunk/src/wind.h
Modified: trunk/src/wind.cpp
===================================================================
--- trunk/src/wind.cpp 2010-06-20 22:35:38 UTC (rev 1151)
+++ trunk/src/wind.cpp 2010-06-20 23:00:30 UTC (rev 1152)
@@ -32,6 +32,7 @@
m_height = text_height(font);
m_font = font;
m_color = color;
+ m_hide_when_empty = false;
}
ConsoleStatusLine::~ConsoleStatusLine()
@@ -273,7 +274,10 @@
return false;
}
}
+ int old_height = m_status_line->get_height();
m_status_line->process_keyboard_input(keycode, scancode);
+ if (m_status_line->get_height() != old_height)
+ set_full_redraw();
return false;
}
Modified: trunk/src/wind.h
===================================================================
--- trunk/src/wind.h 2010-06-20 22:35:38 UTC (rev 1151)
+++ trunk/src/wind.h 2010-06-20 23:00:30 UTC (rev 1152)
@@ -76,6 +76,7 @@
std::string m_text;
FONT *m_font;
int m_color;
+ bool m_hide_when_empty;
bool backspace();
@@ -85,7 +86,13 @@
virtual void redraw_full(BITMAP *bmp, int x, int y);
virtual bool resize(int width, int height);
+ virtual int get_height() const
+ {
+ return m_hide_when_empty && m_text.empty() ? 0 : m_height;
+ }
+ void hide_when_empty() { m_hide_when_empty = true; }
+ void show_when_empty() { m_hide_when_empty = false; }
bool process_keyboard_input(int keycode, int scancode);
const std::string &get_text() const { return m_text; }
@@ -136,6 +143,8 @@
#endif
;
+ void hide_empty_status_line() { m_status_line->hide_when_empty(); }
+ void show_empty_status_line() { m_status_line->show_when_empty(); }
bool process_keyboard_input(int keycode, int scancode);
const char *get_text();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ufo...@li...> - 2011-07-31 22:25:52
|
Revision: 1158
http://ufo2000.svn.sourceforge.net/ufo2000/?rev=1158&view=rev
Author: ssvb
Date: 2011-07-31 22:25:46 +0000 (Sun, 31 Jul 2011)
Log Message:
-----------
Partial fix for issue #617, corrected typos and errors
Fixed mistakes with types 1, 2, 3 and 6 from the issue description.
1) factual mistake, editor screen. "Equipment cost" -> "Soldier cost"
because the cost value is not zero for a soldier without equipment.
2) overlapping message, main menu screen.
"connect to internet server" -> "connect to server". Overlap occured
in 640x480 resolution.
3) duplicating messages, scenario descriptions. Eliminated difference
in duplicating messages "Leader can have ..."/"Leader can use ..."
and "Leader can't have ..."/"Leader can't use ..."
6) typo, scenario description for Search and Destroy. "ennemy" -> "enemy"
From: Fomka <ste...@gm...>
Modified Paths:
--------------
trunk/src/editor.cpp
trunk/src/mainmenu.cpp
trunk/src/scenario.cpp
Modified: trunk/src/editor.cpp
===================================================================
--- trunk/src/editor.cpp 2011-07-07 00:33:10 UTC (rev 1157)
+++ trunk/src/editor.cpp 2011-07-31 22:25:46 UTC (rev 1158)
@@ -380,7 +380,7 @@
char str1[64]; // to adjust position of translated string
//int x1 = 120;
int x2 = 236;
- sprintf(str1, "%s: %4d", _("Equipment cost"), man->calc_full_ammunition_cost() );
+ sprintf(str1, "%s: %4d", _("Soldier cost"), man->calc_full_ammunition_cost() );
int w1 = text_length(g_small_font, str1); // right-justify string
textprintf(screen2, g_small_font, x2-w1, 20, COLOR_GRAY02, "%s", str1);
Modified: trunk/src/mainmenu.cpp
===================================================================
--- trunk/src/mainmenu.cpp 2011-07-07 00:33:10 UTC (rev 1157)
+++ trunk/src/mainmenu.cpp 2011-07-31 22:25:46 UTC (rev 1158)
@@ -240,7 +240,7 @@
the_dialog[MAINMENU_BACKGROUND].proc = d_mainmenu_background_proc;
- the_dialog[MAINMENU_INTERNET].dp = (void *) _("connect to internet server");
+ the_dialog[MAINMENU_INTERNET].dp = (void *) _("connect to server");
the_dialog[MAINMENU_HOTSEAT].dp = (void *) _("start hotseat game");
the_dialog[MAINMENU_GEOSCAPE].dp = (void *) _("show geoscape demo");
the_dialog[MAINMENU_LOADGAME].dp = (void *) _("load saved game");
Modified: trunk/src/scenario.cpp
===================================================================
--- trunk/src/scenario.cpp 2011-07-07 00:33:10 UTC (rev 1157)
+++ trunk/src/scenario.cpp 2011-07-31 22:25:46 UTC (rev 1158)
@@ -196,7 +196,7 @@
briefing_right[SC_CAPTURE][1] = _("from capturing by enemy. He is always visible on ");
briefing_right[SC_CAPTURE][2] = _("your opponent's minimap. ");
- options[SC_CAPTURE][0] = new Option(OPT_SWITCH, 0, _("Leader can have two-handed weapons"), _("Leader can't have two-handed weapons"), false);
+ options[SC_CAPTURE][0] = new Option(OPT_SWITCH, 0, _("Leader can use two-handed weapons"), _("Leader can't use two-handed weapons"), false);
options[SC_CAPTURE][1] = new Option(OPT_NONE);
options[SC_CAPTURE][2] = new Option(OPT_NONE);
}
@@ -206,7 +206,7 @@
name[SC_SEARCH] = ("Search and destroy");
briefing_left[SC_SEARCH][0] = briefing_right[SC_SEARCH][0] = _("You can deploy your units anywhere on the map. ");
- briefing_left[SC_SEARCH][1] = briefing_right[SC_SEARCH][1] = _("Find and kill the ennemy. All units will face ");
+ briefing_left[SC_SEARCH][1] = briefing_right[SC_SEARCH][1] = _("Find and kill the enemy. All units will face ");
briefing_left[SC_SEARCH][2] = briefing_right[SC_SEARCH][2] = _("away from the center and the outside of the map, ");
briefing_left[SC_SEARCH][3] = briefing_right[SC_SEARCH][3] = _("depending on the closest map feature. ");
briefing_left[SC_SEARCH][4] = briefing_right[SC_SEARCH][4] = _(" ");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ufo...@li...> - 2011-12-15 21:14:56
|
Revision: 1169
http://ufo2000.svn.sourceforge.net/ufo2000/?rev=1169&view=rev
Author: ssvb
Date: 2011-12-15 21:14:50 +0000 (Thu, 15 Dec 2011)
Log Message:
-----------
Added "set_status_message" helper function
It can be used to set status message text which is shown
at the top part of the screen and disappears automatically
after the specified timeout elapses.
From: Siarhei Siamashka <sia...@gm...>
Modified Paths:
--------------
trunk/src/global.h
trunk/src/main.cpp
Modified: trunk/src/global.h
===================================================================
--- trunk/src/global.h 2011-12-15 21:09:10 UTC (rev 1168)
+++ trunk/src/global.h 2011-12-15 21:14:50 UTC (rev 1169)
@@ -400,6 +400,9 @@
std::string indent(const std::string &);
bool check_filename_case_consistency(const char *filename);
+void set_status_message(
+ int color, const std::string &msg, unsigned int timeout_sec = 2);
+
/**
* @defgroup battlescape Battlescape Map
* Tile dimensions
Modified: trunk/src/main.cpp
===================================================================
--- trunk/src/main.cpp 2011-12-15 21:09:10 UTC (rev 1168)
+++ trunk/src/main.cpp 2011-12-15 21:14:50 UTC (rev 1169)
@@ -137,6 +137,7 @@
Explosive *elist;
Random *cur_random;
+volatile unsigned int g_1s_timer_ticks = 0;
volatile unsigned int ANIMATION = 0;
volatile int CHANGE = 1;
volatile int MOVEIT = 0;
@@ -174,6 +175,7 @@
g_fps = g_fps_counter;
g_fps_counter = 0;
NOTICE++;
+ g_1s_timer_ticks++;
}
END_OF_FUNCTION(timer_1s);
@@ -1444,11 +1446,39 @@
#endif
}
+static std::string status_message_text;
+static unsigned int status_message_timestamp = 0;
+static unsigned int status_message_timeout = 0;
+static int status_message_color;
+
/**
+ * Set status message text, which will automatically disappear
+ * approximately after 'timeout_sec' seconds (precision is very rough).
+ *
+ * @param color message color
+ * @param msg message text
+ * @param timeout_sec timeout before the message disappears (in seconds)
+ */
+void set_status_message(int color, const std::string &msg, unsigned int timeout_sec)
+{
+ status_message_text = msg;
+ status_message_timestamp = g_1s_timer_ticks;
+ status_message_timeout = timeout_sec;
+ status_message_color = color;
+}
+
+/**
* Show a line informational text at the top of screen.
*/
static void show_status_message_text()
{
+ if (g_1s_timer_ticks - status_message_timestamp < status_message_timeout)
+ {
+ textprintf(screen2, font, 0, 0,
+ status_message_color, "%s", status_message_text.c_str());
+ return;
+ }
+
if (MODE == WATCH)
textprintf(screen2, font, 0, 0, COLOR_WHITE, _("WATCH"));
else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|