[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src game.cpp
From: |
David White |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src game.cpp |
Date: |
Sun, 12 Sep 2004 10:12:28 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: David White <address@hidden> 04/09/12 14:07:22
Modified files:
src : game.cpp
Log message:
implemented sorting of campaigns by rank
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game.cpp.diff?tr1=1.125&tr2=1.126&r1=text&r2=text
Patches:
Index: wesnoth/src/game.cpp
diff -u wesnoth/src/game.cpp:1.125 wesnoth/src/game.cpp:1.126
--- wesnoth/src/game.cpp:1.125 Sat Sep 11 21:22:57 2004
+++ wesnoth/src/game.cpp Sun Sep 12 14:07:21 2004
@@ -1,4 +1,4 @@
-/* $Id: game.cpp,v 1.125 2004/09/11 21:22:57 gruikya Exp $ */
+/* $Id: game.cpp,v 1.126 2004/09/12 14:07:21 Sirp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -62,6 +62,7 @@
#include <cstdlib>
#include <fstream>
#include <iostream>
+#include <iterator>
#include <sstream>
#include <string>
@@ -305,6 +306,11 @@
cfg.read(preprocess_file("data/game.cfg",&defines,&line_src),&line_src);
}
+bool less_campaigns_rank(const config* a, const config* b) {
+ return lexical_cast_default<int>((*a)["rank"],1000) <
+ lexical_cast_default<int>((*b)["rank"],1000);
+}
+
}
int play_game(int argc, char** argv)
@@ -895,11 +901,12 @@
} else if(res == gui::NEW_CAMPAIGN) {
state.campaign_type = "scenario";
- const config::const_child_itors campaigns =
game_config.child_range("campaign");
+ config::child_list campaigns =
game_config.get_children("campaign");
+
std::sort(campaigns.begin(),campaigns.end(),less_campaigns_rank);
std::vector<std::string> campaign_names;
- for(config::const_child_iterator i = campaigns.first; i
!= campaigns.second; ++i) {
+ for(config::child_list::const_iterator i =
campaigns.begin(); i != campaigns.end(); ++i) {
std::stringstream str;
const std::string& icon = (**i)["icon"];
if(icon == "") {
@@ -929,7 +936,7 @@
continue;
}
- const config& campaign = **(campaigns.first+res);
+ const config& campaign = *campaigns[res];
state.scenario = campaign["first_scenario"];
- [Wesnoth-cvs-commits] wesnoth/src game.cpp, Yann Dirson, 2004/09/02
- [Wesnoth-cvs-commits] wesnoth/src game.cpp, David White, 2004/09/08
- [Wesnoth-cvs-commits] wesnoth/src game.cpp,
David White <=
- [Wesnoth-cvs-commits] wesnoth/src game.cpp, David White, 2004/09/12
- [Wesnoth-cvs-commits] wesnoth/src game.cpp, Guillaume Melquiond, 2004/09/18
- [Wesnoth-cvs-commits] wesnoth/src game.cpp, Guillaume Melquiond, 2004/09/18
- [Wesnoth-cvs-commits] wesnoth/src game.cpp, Philippe Plantier, 2004/09/18
- [Wesnoth-cvs-commits] wesnoth/src game.cpp, David White, 2004/09/18
- [Wesnoth-cvs-commits] wesnoth/src game.cpp, Guillaume Melquiond, 2004/09/19
- [Wesnoth-cvs-commits] wesnoth/src game.cpp, Yann Dirson, 2004/09/19