1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
--- x11/viewport.cpp.orig 2012-05-27 06:52:29.000000000 +0900
+++ x11/viewport.cpp 2012-05-27 06:52:59.000000000 +0900
@@ -44,8 +44,9 @@
#include <X11/Xos.h>
#include <X11/keysym.h>
}
-#include <strstream.h>
+#include <sstream>
+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());
}
|