[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src playturn.cpp replay.cpp replay.hpp
From: |
David White |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src playturn.cpp replay.cpp replay.hpp |
Date: |
Sun, 03 Oct 2004 15:29:48 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: David White <address@hidden> 04/10/03 19:23:10
Modified files:
src : playturn.cpp replay.cpp replay.hpp
Log message:
fixed bug in replay with disbanding units
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playturn.cpp.diff?tr1=1.275&tr2=1.276&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/replay.cpp.diff?tr1=1.80&tr2=1.81&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/replay.hpp.diff?tr1=1.26&tr2=1.27&r1=text&r2=text
Patches:
Index: wesnoth/src/playturn.cpp
diff -u wesnoth/src/playturn.cpp:1.275 wesnoth/src/playturn.cpp:1.276
--- wesnoth/src/playturn.cpp:1.275 Fri Oct 1 00:13:47 2004
+++ wesnoth/src/playturn.cpp Sun Oct 3 19:23:10 2004
@@ -1,4 +1,4 @@
-/* $Id: playturn.cpp,v 1.275 2004/10/01 00:13:47 Sirp Exp $ */
+/* $Id: playturn.cpp,v 1.276 2004/10/03 19:23:10 Sirp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -1742,6 +1742,7 @@
}
units_.erase(units_.begin() + index);
+ recorder.add_disband(index);
return gui::dialog_button_action::DELETE_ITEM;
} else {
return gui::dialog_button_action::NO_EFFECT;
Index: wesnoth/src/replay.cpp
diff -u wesnoth/src/replay.cpp:1.80 wesnoth/src/replay.cpp:1.81
--- wesnoth/src/replay.cpp:1.80 Mon Sep 13 03:16:19 2004
+++ wesnoth/src/replay.cpp Sun Oct 3 19:23:10 2004
@@ -1,4 +1,4 @@
-/* $Id: replay.cpp,v 1.80 2004/09/13 03:16:19 Sirp Exp $ */
+/* $Id: replay.cpp,v 1.81 2004/10/03 19:23:10 Sirp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -284,6 +284,19 @@
cmd->add_child("recall",val);
}
+void replay::add_disband(int value)
+{
+ config* const cmd = add_command();
+
+ config val;
+
+ char buf[100];
+ sprintf(buf,"%d",value);
+ val["value"] = buf;
+
+ cmd->add_child("disband",val);
+}
+
void replay::add_movement(const gamemap::location& a,const gamemap::location&
b)
{
add_pos("move",a,b);
@@ -714,15 +727,15 @@
}
else if((child = cfg->child("recall")) != NULL) {
- player_info
*player=state_of_game.get_player(teams[team_num].save_id());
- if(!player) {
+ player_info* player =
state_of_game.get_player(current_team.save_id());
+ if(player == NULL) {
std::cerr << "illegal recall\n";
throw replay::error();
}
std::sort(player->available_units.begin(),player->available_units.end(),compare_unit_values());
- const std::string recall_num = (*child)["value"];
+ const std::string& recall_num = (*child)["value"];
const int val = atoi(recall_num.c_str());
gamemap::location loc(*child);
@@ -739,6 +752,25 @@
fix_shroud = true;
}
+ else if((child = cfg->child("disband")) != NULL) {
+ player_info* const player =
state_of_game.get_player(current_team.save_id());
+ if(player == NULL) {
+ std::cerr << "illegal disband\n";
+ throw replay::error();
+ }
+
+
std::sort(player->available_units.begin(),player->available_units.end(),compare_unit_values());
+ const std::string& unit_num = (*child)["value"];
+ const int val = atoi(unit_num.c_str());
+
+ if(val >= 0 && val <
int(player->available_units.size())) {
+
player->available_units.erase(player->available_units.begin()+val);
+ } else {
+ std::cerr << "illegal disband\n";
+ throw replay::error();
+ }
+ }
+
else if((child = cfg->child("move")) != NULL) {
const config* const destination =
child->child("destination");
Index: wesnoth/src/replay.hpp
diff -u wesnoth/src/replay.hpp:1.26 wesnoth/src/replay.hpp:1.27
--- wesnoth/src/replay.hpp:1.26 Wed Jun 23 23:43:38 2004
+++ wesnoth/src/replay.hpp Sun Oct 3 19:23:10 2004
@@ -1,4 +1,4 @@
-/* $Id: replay.hpp,v 1.26 2004/06/23 23:43:38 Sirp Exp $ */
+/* $Id: replay.hpp,v 1.27 2004/10/03 19:23:10 Sirp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -48,6 +48,7 @@
void add_recruit(int unit_index, const gamemap::location& loc);
void add_recall(int unit_index, const gamemap::location& loc);
+ void add_disband(int unit_index);
void add_movement(const gamemap::location& a, const gamemap::location&
b);
void add_attack(const gamemap::location& a, const gamemap::location& b,
int weapon);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src playturn.cpp replay.cpp replay.hpp,
David White <=