[Freeciv-Dev] (PR#13933) Your attacking battleship succeeded...
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13933 >
> [jdorje - Sat Sep 10 06:45:28 2005]:
>
> "Your attacking Battleship succeeded against Mehmet's Musketeers outside
> Tuncelli!"
>
> For me the information about the city isn't that important (though it
> doesn't hurt unless it makes the text too long to fit on one line). But
> what I would like to know is that collateral damage destroyed 4 other
units:
>
> "Your attacking Battleship defeated Mehmet's Musketeers (and 4 other
> units)!"
This patch adds "(and %d other units)" to the message.
This means the message sent to the killer has to be generated inside
kill_unit. This is better since that's where the other combat messages
are generated. It also means the vet parameter has to be passed to
kill_unit.
However because of the large number of cases there are currently 4
different strings. I didn't add all the cases I wanted since that would
take about 10 different separate notify cases. This could be solved by
breaking the string down into phrases and generating each phrase
separately; however that might fail for some languages.
Current strings:
"Your attacking Battleship succeeded against John's Phalanx near
Wilmington!"
"Your attacking Battleship succeeded against John's Phalanx near
Wilmington and became more experienced!"
"Your attacking Battleship succeeded against John's Phalanx (and 2
other units) near Wilmington!"
"Your attacking Battleship succeeded against John's Phalanx (and 2
other units) near Wilmington and became more experienced!"
Yes this makes the strings longer. If they're too long we can remove
one of the phrases.
Other cases I would like to add:
"Your attacking Battleship succeeded against John's Phalanx (and
Catapult) near Wilmington!"
"Your attacking Battleship succeeded against John's Phalanx (and
Catapult) near Wilmington and became more experienced!"
"Your attacking Battleship succeeded against John's Phalanx (and
Mark's Catapult) near Wilmington!"
"Your attacking Battleship succeeded against John's Phalanx (and
Mark's Catapult) near Wilmington and became more experienced!"
Untested.
-jason
Index: server/unithand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.351
diff -p -u -r1.351 unithand.c
--- server/unithand.c 5 Sep 2005 15:55:47 -0000 1.351
+++ server/unithand.c 14 Sep 2005 03:32:28 -0000
@@ -885,31 +885,11 @@ static void handle_unit_attack_request(s
unit_owner(pdefender)->name, unit_type(pdefender)->name);
punit->moved = TRUE; /* We moved */
- if (vet && !unit_flag(punit, F_MISSILE)) {
- notify_player(unit_owner(pwinner), punit->tile,
- E_UNIT_WIN_ATT,
- _("Your attacking %s succeeded"
- " against %s's %s%s and became more experienced!"),
- unit_name(pwinner->type),
- unit_owner(plooser)->name, unit_name(plooser->type),
- get_location_str_at(unit_owner(pwinner),
- plooser->tile));
- } else {
- notify_player(unit_owner(pwinner), punit->tile,
- E_UNIT_WIN_ATT,
- _("Your attacking %s succeeded"
- " against %s's %s%s!"),
- unit_name(pwinner->type),
- unit_owner(plooser)->name, unit_name(plooser->type),
- get_location_str_at(unit_owner(pwinner),
- plooser->tile));
+ kill_unit(pwinner, plooser, vet && !unit_flag(punit, F_MISSILE));
+ if (unit_flag(pwinner, F_MISSILE)) {
+ wipe_unit(pwinner);
+ return;
}
- kill_unit(pwinner, plooser);
- /* no longer pplayer - want better msgs -- Syela */
- }
- if (pwinner == punit && unit_flag(punit, F_MISSILE)) {
- wipe_unit(pwinner);
- return;
}
/* If attacker wins, and occupychance > 0, it might move in. Don't move in
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.385
diff -p -u -r1.385 unittools.c
--- server/unittools.c 8 Sep 2005 19:47:38 -0000 1.385
+++ server/unittools.c 14 Sep 2005 03:32:29 -0000
@@ -1616,15 +1616,15 @@ void wipe_unit(struct unit *punit)
}
/**************************************************************************
-this is a highlevel routine
-the unit has been killed in combat => all other units on the
-tile dies unless ...
+ Called when one unit kills another in combat (this function is only
+ called in one place). It handles all side effects including
+ notifications and killstack.
**************************************************************************/
-void kill_unit(struct unit *pkiller, struct unit *punit)
+void kill_unit(struct unit *pkiller, struct unit *punit, bool vet)
{
struct player *pplayer = unit_owner(punit);
struct player *destroyer = unit_owner(pkiller);
- char *loc_str = get_location_str_in(pplayer, punit->tile);
+ const char *loc_str = get_location_str_in(pplayer, punit->tile);
int ransom, unitcount = 0;
/* barbarian leader ransom hack */
@@ -1650,6 +1650,22 @@ void kill_unit(struct unit *pkiller, str
}
if (!is_stack_vulnerable(punit->tile) || unitcount == 1) {
+ if (vet) {
+ notify_player(unit_owner(pkiller), pkiller->tile, E_UNIT_WIN_ATT,
+ _("Your attacking %s succeeded"
+ " against %s's %s%s and became more experienced!"),
+ unit_name(pkiller->type),
+ unit_owner(punit)->name, unit_name(punit->type),
+ get_location_str_at(unit_owner(pkiller),
+ punit->tile));
+ } else {
+ notify_player(unit_owner(pkiller), pkiller->tile, E_UNIT_WIN_ATT,
+ _("Your attacking %s succeeded against %s's %s%s!"),
+ unit_name(pkiller->type),
+ unit_owner(punit)->name, unit_name(punit->type),
+ get_location_str_at(unit_owner(pkiller),
+ punit->tile));
+ }
notify_player(pplayer, punit->tile, E_UNIT_LOST,
_("%s lost to an attack by %s's %s%s."),
unit_type(punit)->name, destroyer->name,
@@ -1662,9 +1678,8 @@ void kill_unit(struct unit *pkiller, str
int num_killed[MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS];
struct unit *other_killed[MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS];
- if (!(unitcount > 1)) {
- die("Error in kill_unit, unitcount is %i", unitcount);
- }
+ assert(unitcount > 1);
+
/* initialize */
for (i = 0; i<MAX_NUM_PLAYERS+MAX_NUM_BARBARIANS; i++) {
num_killed[i] = 0;
@@ -1677,10 +1692,37 @@ void kill_unit(struct unit *pkiller, str
num_killed[vunit->owner->player_no]++;
if (vunit != punit) {
other_killed[vunit->owner->player_no] = vunit;
+ other_killed[destroyer->player_no] = vunit;
}
}
} unit_list_iterate_end;
+ /* Inform the destroyer: lots of different cases here! */
+ if (vet) {
+ notify_player(unit_owner(pkiller), pkiller->tile, E_UNIT_WIN_ATT,
+ PL_("Your attacking %s succeeded against %s's %s "
+ "(and %d other unit)%s and became more experienced!",
+ "Your attacking %s succeeded against %s's %s "
+ "(and %d other units)%s and became more experienced!",
+ unitcount),
+ unit_name(pkiller->type),
+ unit_owner(punit)->name, unit_name(punit->type),
+ unitcount,
+ get_location_str_at(unit_owner(pkiller),
+ punit->tile));
+ } else {
+ notify_player(unit_owner(pkiller), pkiller->tile, E_UNIT_WIN_ATT,
+ PL_("Your attacking %s succeeded against %s's %s "
+ "(and %d other unit)%s!",
+ "Your attacking %s succeeded against %s's %s "
+ "(and %d other units)%s!", unitcount),
+ unit_name(pkiller->type),
+ unit_owner(punit)->name, unit_name(punit->type),
+ unitcount,
+ get_location_str_at(unit_owner(pkiller),
+ punit->tile));
+ }
+
/* inform the owners: this only tells about owned units that were killed.
* there may have been 20 units who died but if only 2 belonged to the
* particular player they'll only learn about those.
Index: server/unittools.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.h,v
retrieving revision 1.75
diff -p -u -r1.75 unittools.h
--- server/unittools.h 22 Jul 2005 16:18:08 -0000 1.75
+++ server/unittools.h 14 Sep 2005 03:32:29 -0000
@@ -63,7 +63,7 @@ struct unit *create_unit_full(struct pla
struct unit *ptrans);
void wipe_unit(struct unit *punit);
void wipe_unit_spec_safe(struct unit *punit, bool wipe_cargo);
-void kill_unit(struct unit *pkiller, struct unit *punit);
+void kill_unit(struct unit *pkiller, struct unit *punit, bool vet);
/* sending to client */
void package_unit(struct unit *punit, struct packet_unit_info *packet);
|
|