[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src config.cpp gamestatus.cpp playturn....
From: |
Guillaume Melquiond |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src config.cpp gamestatus.cpp playturn.... |
Date: |
Fri, 28 Jan 2005 15:17:46 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Guillaume Melquiond <address@hidden> 05/01/28 20:17:46
Modified files:
src : config.cpp gamestatus.cpp playturn.cpp
replay.cpp
Log message:
From a language lawyer PoV, size_t is not %lu. But we would not have to
care, if it wasn't wrong with some ABIs too. So let's be cautious and use C++
idioms here.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/config.cpp.diff?tr1=1.122&tr2=1.123&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/gamestatus.cpp.diff?tr1=1.52&tr2=1.53&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playturn.cpp.diff?tr1=1.324&tr2=1.325&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/replay.cpp.diff?tr1=1.89&tr2=1.90&r1=text&r2=text
Patches:
Index: wesnoth/src/config.cpp
diff -u wesnoth/src/config.cpp:1.122 wesnoth/src/config.cpp:1.123
--- wesnoth/src/config.cpp:1.122 Sun Jan 23 16:30:23 2005
+++ wesnoth/src/config.cpp Fri Jan 28 20:17:46 2005
@@ -1,4 +1,4 @@
-/* $Id: config.cpp,v 1.122 2005/01/23 16:30:23 j_daniel Exp $ */
+/* $Id: config.cpp,v 1.123 2005/01/28 20:17:46 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -1576,13 +1576,14 @@
} else {
//we have to work out what the most appropriate
operation --
//delete, insert, or change is the best to get
b[bi] looking like a[ai]
+ std::stringstream buf;
+
//if b has more elements than a, then we assume
this element is an
//element that needs deleting
if(b.size() - bi > a.size() - ai) {
config& new_delete =
res.add_child("delete_child");
- char buf[50];
- sprintf(buf,"%lu",bi-ndeletes);
- new_delete.values["index"] = buf;
+ buf << bi - ndeletes;
+ new_delete.values["index"] = buf.str();
new_delete.add_child(*itor);
++ndeletes;
@@ -1593,9 +1594,8 @@
//element that needs inserting
else if(b.size() - bi < a.size() - ai) {
config& new_insert =
res.add_child("insert_child");
- char buf[50];
- sprintf(buf,"%lu",ai);
- new_insert.values["index"] = buf;
+ buf << ai;
+ new_insert.values["index"] = buf.str();
new_insert.add_child(*itor,*a[ai]);
++ai;
@@ -1605,9 +1605,8 @@
//changing this element to match
else {
config& new_change =
res.add_child("change_child");
- char buf[50];
- sprintf(buf,"%lu",bi);
- new_change.values["index"] = buf;
+ buf << bi;
+ new_change.values["index"] = buf.str();
new_change.add_child(*itor,a[ai]->get_diff(*b[bi]));
++ai;
Index: wesnoth/src/gamestatus.cpp
diff -u wesnoth/src/gamestatus.cpp:1.52 wesnoth/src/gamestatus.cpp:1.53
--- wesnoth/src/gamestatus.cpp:1.52 Sun Jan 23 16:05:03 2005
+++ wesnoth/src/gamestatus.cpp Fri Jan 28 20:17:46 2005
@@ -1,4 +1,4 @@
-/* $Id: gamestatus.cpp,v 1.52 2005/01/23 16:05:03 j_daniel Exp $ */
+/* $Id: gamestatus.cpp,v 1.53 2005/01/28 20:17:46 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -102,12 +102,12 @@
void gamestatus::write(config& cfg) const
{
- char buf[50];
- sprintf(buf,"%lu",turn_);
- cfg["turn_at"] = buf;
-
- sprintf(buf,"%d",numTurns_);
- cfg["turns"] = buf;
+ std::stringstream buf;
+ buf << turn_;
+ cfg["turn_at"] = buf.str();
+ buf.str(std::string());
+ buf << numTurns_;
+ cfg["turns"] = buf.str();
std::vector<time_of_day>::const_iterator t;
for(t = times_.begin(); t != times_.end(); ++t) {
Index: wesnoth/src/playturn.cpp
diff -u wesnoth/src/playturn.cpp:1.324 wesnoth/src/playturn.cpp:1.325
--- wesnoth/src/playturn.cpp:1.324 Thu Jan 27 17:19:16 2005
+++ wesnoth/src/playturn.cpp Fri Jan 28 20:17:46 2005
@@ -1,4 +1,4 @@
-/* $Id: playturn.cpp,v 1.324 2005/01/27 17:19:16 j_daniel Exp $ */
+/* $Id: playturn.cpp,v 1.325 2005/01/28 20:17:46 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -1607,9 +1607,9 @@
start["snapshot"] = "yes";
- char buf[50];
- sprintf(buf,"%lu",gui_.playing_team());
- start["playing_team"] = buf;
+ std::stringstream buf;
+ buf << gui_.playing_team();
+ start["playing_team"] = buf.str();
for(std::vector<team>::const_iterator t = teams_.begin(); t !=
teams_.end(); ++t) {
const int side_num = t - teams_.begin() + 1;
@@ -1617,8 +1617,9 @@
config& side = start.add_child("side");
t->write(side);
side["no_leader"] = "yes";
- sprintf(buf,"%d",side_num);
- side["side"] = buf;
+ buf.str(std::string());
+ buf << side_num;
+ side["side"] = buf.str();
for(std::map<gamemap::location,unit>::const_iterator i =
units_.begin(); i != units_.end(); ++i) {
if(i->second.side() == side_num) {
Index: wesnoth/src/replay.cpp
diff -u wesnoth/src/replay.cpp:1.89 wesnoth/src/replay.cpp:1.90
--- wesnoth/src/replay.cpp:1.89 Sun Jan 23 16:13:12 2005
+++ wesnoth/src/replay.cpp Fri Jan 28 20:17:46 2005
@@ -1,4 +1,4 @@
-/* $Id: replay.cpp,v 1.89 2005/01/23 16:13:12 j_daniel Exp $ */
+/* $Id: replay.cpp,v 1.90 2005/01/28 20:17:46 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -105,9 +105,9 @@
config create_verification(const unit_map& units)
{
config res;
- char buf[50];
- sprintf(buf,"%lu",units.size());
- res["num_units"] = buf;
+ std::stringstream buf;
+ buf << units.size();
+ res["num_units"] = buf.str();
for(unit_map::const_iterator i = units.begin(); i !=
units.end(); ++i) {
config u;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src config.cpp gamestatus.cpp playturn....,
Guillaume Melquiond <=