Merge lp:~brandesign/armagetronad/0.4-conquest-output into lp:~armagetronad-dev/armagetronad/0.4-armagetronad-work

Proposed by David Brandes
Status: Merged
Merged at revision: 1450
Proposed branch: lp:~brandesign/armagetronad/0.4-conquest-output
Merge into: lp:~armagetronad-dev/armagetronad/0.4-armagetronad-work
Diff against target: 121 lines (+65/-2)
3 files modified
NEWS (+2/-0)
language/english_base.txt (+3/-0)
src/tron/zone/zFortress.cpp (+60/-2)
To merge this branch: bzr merge lp:~brandesign/armagetronad/0.4-conquest-output
Reviewer Review Type Date Requested Status
dlh Needs Fixing
Review via email: mp+130341@code.launchpad.net

This proposal supersedes a proposal from 2012-10-18.

Description of the change

This adds the command CONDENSE_CONQUEST_OUTPUT. If set to 1 the output gets condensed into 1 line like:
Team 1, Team 2 and Team 3 where awarded 20 Points for conquering Team 4's base

To post a comment you must log in.
Revision history for this message
dlh (dlh) wrote :

== Make more translatable

I think this can be cleaned up a little. It's also difficult to translate (hardcoded " and ").

I think a better solution is: build up a list of team names, and then join all of the strings except the penultimate together (either using boost::algorithm::join or a custom implementation). The last team name would be the \4 parameter to the localized string.

So, we currently have:
* player_win_conquest_specific \1 was awarded \2 points for conquering \3's base.\n

And the new localized string for the condensed message shares the same parameters with the additional \4 parameter:
* players_win_condense_conquest \1, and \4 were awarded \2 points for conquering \3's base.\n

I think localized strings should be the full string—it's easier for translators to understand. Simply adding a new localized string for " and " can be confusing and may require looking at the source code to see how it's used.

== Should this be a configurable setting?

Does this need to be a configurable setting? And if it a setting, maybe it should be enabled by default.

== Other minor critiques

* "where awarded" should be "were awarded"
* The RequestSync() you added at the end isn't necessary.
* "score > 0 ? score : -score" is abs(score), but it looks like this was copied from eTeam::AddScore().

review: Needs Fixing
Revision history for this message
dlh (dlh) wrote :

Can't edit comments…

This:

> I think a better solution is: build up a list of team names, and then join all of the strings except the ***penultimate*** […]

Should be:

> I think a better solution is: build up a list of team names, and then join all of the strings except the ***last*** […]

Revision history for this message
Yann Kaiser (epsy) wrote :

I generalised your patch and merged it. Moved most of the logic to templates for "tString << tArray<T>/std::vector<T>/std::list<T>" so that anything can pass a pointer list to a tOutput in the future.

It might still raise some localisation issues but they can be fixed as they come up. I forgot about putting abs(score) there, will do later.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2012-10-15 16:28:12 +0000
3+++ NEWS 2012-10-18 13:21:34 +0000
4@@ -58,6 +58,8 @@
5 - user*.cfg now resides in UserConfigDir.
6 - Configuration files, with the exception of legacy user*.cfg files, are no longer
7 read from the var directory.
8+- New command CONDENSE_CONQUEST_OUTPUT. If set to 1 the zone conquering output gets condensed into 1 line like:
9+ Team 1, Team 2 and Team 3 where awarded 20 Points for conquering Team 4's base
10
11 Changes since 0.3.0
12 ===================
13
14=== modified file 'language/english_base.txt'
15--- language/english_base.txt 2012-10-15 16:28:12 +0000
16+++ language/english_base.txt 2012-10-18 13:21:34 +0000
17@@ -341,6 +341,8 @@
18 win_zone_deaths_help A value of 1 turns it into a death zone.
19 win_zone_randomness_help Randomness factor of the initial win zone position. 0 fixes it at the arena center, 1 spreads the zone all over it.
20
21+condense_conquest_output_help Zone conquest output condensed into one line
22+
23 game_timeout_help Base timeout for game state synchronisation; gives approximately the maximum time between rounds.
24 last_chat_break_time_help Last round time a player in chat mode is able to pause the timer
25 extra_round_time_help Length of an extra pause at the beginning of the round
26@@ -2845,6 +2847,7 @@
27 player_win_held_fortress \1 was awarded \2 points for holding the base.\n
28 player_lose_held_fortress \1 lost \2 points for being too defensive.\n
29 player_win_conquest_specific \1 was awarded \2 points for conquering \3's base.\n
30+players_win_condense_conquest \1 where awarded \2 points for conquering \3's base.\n
31 player_kill_collapse \1 was eradicated by its collapsing zone.\n
32 player_win_hole \1 got \2 points for a sacrifice for the good of the team.\n
33 player_lose_hole 0xffff00ZOMG! 0xff7f00HOLER!!1!!0xRESETT \1 lost \2 points for being a cheap ass lamer.\n
34
35=== modified file 'src/tron/zone/zFortress.cpp'
36--- src/tron/zone/zFortress.cpp 2012-07-23 19:32:52 +0000
37+++ src/tron/zone/zFortress.cpp 2012-10-18 13:21:34 +0000
38@@ -132,6 +132,10 @@
39 static bool sg_baseEnemyRespawn = false;
40 static tSettingItem<bool> sg_baseEnemyRespawnConfig ("BASE_ENEMY_RESPAWN", sg_baseEnemyRespawn);
41
42+//condense fort zone conquered output into one line for multiple winers.
43+static bool sg_condenseConquestOutput = false;
44+static tSettingItem<bool> sg_condenseConquestOutputConfig("CONDENSE_CONQUEST_OUTPUT", sg_condenseConquestOutput);
45+
46 void zFortressZone::setupVisuals(gParser::State_t & state)
47 {
48 REAL tpR[] = {.0f, .3f};
49@@ -524,9 +528,64 @@
50 }
51
52 int score = totalScore / (int)enemies_.size();
53+ int tCount = 0;
54+ tColoredString TeamOutputNames;
55+ tColoredString lastTeam;
56 for ( TeamArray::iterator iter = enemies_.begin(); iter != enemies_.end(); ++iter )
57 {
58- (*iter)->AddScore( score, win, tOutput() );
59+ if ( sg_condenseConquestOutput )
60+ {
61+ (*iter)->AddScore( score);
62+
63+ if ( tCount == 0 )
64+ {
65+ lastTeam = (*iter)->GetColoredName();
66+ }
67+ else if ( tCount == 1 )
68+ {
69+ TeamOutputNames << lastTeam;
70+ lastTeam = (*iter)->GetColoredName();
71+ }
72+ else
73+ {
74+ TeamOutputNames << tColoredString::ColorString(1,1,1) << ", " << lastTeam;
75+ lastTeam = (*iter)->GetColoredName();
76+ }
77+
78+ tCount++;
79+ }
80+ else
81+ {
82+ (*iter)->AddScore( score, win, tOutput() );
83+ }
84+ }
85+
86+ if ( sg_condenseConquestOutput )
87+ {
88+ if ( tCount == 1 )
89+ {
90+ TeamOutputNames << tColoredString::ColorString(1,1,1) << lastTeam;
91+ }
92+ else
93+ {
94+ TeamOutputNames << tColoredString::ColorString(1,1,1) << " and " << lastTeam;
95+ }
96+
97+ tOutput message;
98+ message.SetTemplateParameter(1, TeamOutputNames);
99+ message.SetTemplateParameter(2, score > 0 ? score : -score);
100+ message.SetTemplateParameter(3, team->GetColoredName());
101+ if ( tCount == 1 )
102+ {
103+ message << "$player_win_conquest_specific";
104+ }
105+ else
106+ {
107+ message << "$players_win_condense_conquest";
108+ }
109+
110+ sn_ConsoleOut(message);
111+ RequestSync(true);
112 }
113 }
114
115@@ -536,7 +595,6 @@
116 static const char* message="$player_win_conquest";
117 sg_DeclareWinner( enemies_[0], message );
118 }
119-
120 CheckSurvivor();
121 }
122

Subscribers

People subscribed via source and target branches