[Freeciv-Dev] Re: (PR#2290) [rff] onsetwar
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Fri, Nov 29, 2002 at 05:55:52AM -0800, Per I. Mathisen via RT wrote:
>
> [ue80@xxxxxxxxxxxxxxxxxxx - Sun Nov 10 17:36:03 2002]:
> > The Paratroopers thing is a bug in freeciv, so it has to be changed
> > with another patch.
> >
> > Nukes should be done with the Borderpatch.
>
> There is no updated patch attached to this issue in RT.
>
> Paratroopers have now been fixed in cvs. So there is no longer an
> excuse not to check them for onsetwar as well.
The solution in cvs is ok for my onsetwar-patch. Doing damage
because hostile actions isn't possible until onsetwar is over.
> Nukes... well, ok, let's not bother.
I don't bother, i only wanted to say that i looked at nearly all
posibilities where there could be problems.
Thomas
--
Thomas Strub *** eMail ue80@xxxxxxxxxxxxxxxxxxx
Nur weil das Aufzeichnen, Kopieren und Schnüffeln bei elektronischem
Datenverkehr leichter als bei der klassischen Post ist, darf man es nicht
einfach tun.
Index: common/game.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.c,v
retrieving revision 1.152
diff -u -r1.152 game.c
--- common/game.c 2002/11/14 09:15:01 1.152
+++ common/game.c 2002/12/07 18:10:10
@@ -693,6 +693,7 @@
game.auto_ai_toggle = GAME_DEFAULT_AUTO_AI_TOGGLE;
game.notradesize = GAME_DEFAULT_NOTRADESIZE;
game.fulltradesize = GAME_DEFAULT_FULLTRADESIZE;
+ game.onsetwar = GAME_DEFAULT_ONSETWAR;
game.barbarianrate = GAME_DEFAULT_BARBARIANRATE;
game.onsetbarbarian = GAME_DEFAULT_ONSETBARBARIAN;
game.nbarbarians = 0;
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.116
diff -u -r1.116 game.h
--- common/game.h 2002/11/11 10:00:47 1.116
+++ common/game.h 2002/12/07 18:10:10
@@ -87,6 +87,7 @@
int min_players, max_players, nplayers;
int aifill;
int notradesize, fulltradesize;
+ int onsetwar;
int barbarianrate;
int onsetbarbarian;
int nbarbarians;
@@ -415,6 +416,11 @@
#define GAME_DEFAULT_FULLTRADESIZE 1
#define GAME_MIN_FULLTRADESIZE 1
#define GAME_MAX_FULLTRADESIZE 50
+
+#define GAME_DEFAULT_ONSETWAR GAME_START_YEAR
+#define GAME_MIN_ONSETWAR GAME_START_YEAR
+#define GAME_MAX_ONSETWAR GAME_MAX_END_YEAR
+
#define GAME_DEFAULT_BARBARIANRATE 2
#define GAME_MIN_BARBARIANRATE 0
Index: common/player.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.c,v
retrieving revision 1.103
diff -u -r1.103 player.c
--- common/player.c 2002/11/18 12:19:51 1.103
+++ common/player.c 2002/12/07 18:10:10
@@ -563,13 +563,28 @@
return ds == DS_NO_CONTACT;
}
+
/***************************************************************
+returns true iff the time to onset war is over.
+***************************************************************/
+bool onset_war_over(const struct player *pplayer,
+ const struct player *pplayer2)
+{
+ if (game.year < game.onsetwar){
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+/***************************************************************
returns true iff players can attack each other.
***************************************************************/
bool pplayers_at_war(const struct player *pplayer,
const struct player *pplayer2)
{
enum diplstate_type ds = pplayer_get_diplstate(pplayer, pplayer2)->type;
+ if (!onset_war_over(pplayer,pplayer2)) return FALSE;
if (pplayer == pplayer2) return FALSE;
if (is_barbarian(pplayer) || is_barbarian(pplayer2))
return TRUE;
Index: common/player.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.h,v
retrieving revision 1.88
diff -u -r1.88 player.h
--- common/player.h 2002/11/25 19:18:09 1.88
+++ common/player.h 2002/12/07 18:10:10
@@ -252,6 +252,8 @@
*pplayer2);
bool pplayers_no_contact(const struct player *pplayer,
const struct player *pplayer2);
+bool onset_war_over(const struct player *pplayer,
+ const struct player *pplayer2);
bool pplayers_at_war(const struct player *pplayer,
const struct player *pplayer2);
bool pplayers_allied(const struct player *pplayer,
Index: server/diplomats.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplomats.c,v
retrieving revision 1.32
diff -u -r1.32 diplomats.c
--- server/diplomats.c 2002/11/14 09:15:04 1.32
+++ server/diplomats.c 2002/12/07 18:10:11
@@ -71,6 +71,16 @@
if (!cplayer || !pplayers_at_war(pplayer, cplayer))
return;
+ if (!onset_war_over(pplayer, cplayer)) {
+ notify_player_ex(pplayer, pdiplomat->x, pdiplomat->y,
+ E_MY_DIPLOMAT_FAILED,
+ _("Game: You can't poison cities before year %d."),
+ game.onsetwar);
+ return;
+ }
+
+
+
freelog (LOG_DEBUG, "poison: unit: %d", pdiplomat->id);
/* If not a Spy, can't poison. */
@@ -336,6 +346,14 @@
if (!uplayer || pplayers_allied(pplayer, uplayer))
return;
+ if (!onset_war_over(pplayer, uplayer)) {
+ notify_player_ex(pplayer, pdiplomat->x, pdiplomat->y,
+ E_MY_DIPLOMAT_FAILED,
+ _("Game: You can't sabotage unit before year %d."),
+ game.onsetwar);
+ return;
+ }
+
freelog (LOG_DEBUG, "sabotage-unit: unit: %d", pdiplomat->id);
/* If not a Spy, can't sabotage unit. */
@@ -386,6 +404,7 @@
- It's not the only unit on the square
(this is handled outside this function).
- You are allied with the unit owner.
+ - Its before onset-war is over.
- Otherwise, the unit will be bribed.
- A successful briber will try to move onto the victim's square.
@@ -403,7 +422,13 @@
/* We might make it allowable in peace with a liss of reputaion */
if (!uplayer || pplayers_allied(pplayer, uplayer))
return;
-
+ if (!onset_war_over(pplayer, uplayer)) {
+ notify_player_ex(pplayer, pdiplomat->x, pdiplomat->y,
+ E_MY_DIPLOMAT_FAILED,
+ _("Game: You can't bribe units before year %d."),
+ game.onsetwar);
+ return;
+ }
freelog (LOG_DEBUG, "bribe-unit: unit: %d", pdiplomat->id);
/* Update bribe cost. */
@@ -509,6 +534,14 @@
if ((cplayer == pplayer) || !cplayer)
return;
+ if (!onset_war_over(pplayer, cplayer)) {
+ notify_player_ex(pplayer, pdiplomat->x, pdiplomat->y,
+ E_MY_DIPLOMAT_FAILED,
+ _("Game: You can't steal techs before year %d."),
+ game.onsetwar);
+ return;
+ }
+
freelog (LOG_DEBUG, "steal-tech: unit: %d", pdiplomat->id);
/* If not a Spy, do something random. */
@@ -719,6 +752,14 @@
if (!cplayer || pplayers_allied(cplayer, pplayer))
return;
+ if (!onset_war_over(pplayer, cplayer)) {
+ notify_player_ex(pplayer, pdiplomat->x, pdiplomat->y,
+ E_MY_DIPLOMAT_FAILED,
+ _("Game: You can't incite revolt before year %d."),
+ game.onsetwar);
+ return;
+ }
+
freelog (LOG_DEBUG, "incite: unit: %d", pdiplomat->id);
/* Check for city from a bribable government. */
@@ -849,6 +890,14 @@
if (!cplayer || !pplayers_at_war(pplayer, cplayer))
return;
+ if (!onset_war_over(pplayer, cplayer)) {
+ notify_player_ex(pplayer, pdiplomat->x, pdiplomat->y,
+ E_MY_DIPLOMAT_FAILED,
+ _("Game: You can't sabotage before year %d."),
+ game.onsetwar);
+ return;
+ }
+
freelog (LOG_DEBUG, "sabotage: unit: %d", pdiplomat->id);
/* If not a Spy, do something random. */
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.99
diff -u -r1.99 savegame.c
--- server/savegame.c 2002/11/19 13:35:31 1.99
+++ server/savegame.c 2002/12/07 18:10:12
@@ -1862,6 +1862,8 @@
"game.turnblock");
game.fixedlength = secfile_lookup_bool_default(file,game.fixedlength,
"game.fixedlength");
+ game.onsetwar = secfile_lookup_int_default(file, game.onsetwar,
+ "game.onsetwar");
game.barbarianrate = secfile_lookup_int_default(file, game.barbarianrate,
"game.barbarians");
game.onsetbarbarian = secfile_lookup_int_default(file, game.onsetbarbarian,
@@ -2192,6 +2194,7 @@
secfile_insert_bool(file, game.turnblock, "game.turnblock");
secfile_insert_bool(file, game.savepalace, "game.savepalace");
secfile_insert_bool(file, game.fixedlength, "game.fixedlength");
+ secfile_insert_int(file, game.onsetwar, "game.onsetwar");
secfile_insert_int(file, game.barbarianrate, "game.barbarians");
secfile_insert_int(file, game.onsetbarbarian, "game.onsetbarbs");
secfile_insert_int(file, game.occupychance, "game.occupychance");
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.266
diff -u -r1.266 stdinhand.c
--- server/stdinhand.c 2002/11/25 19:18:09 1.266
+++ server/stdinhand.c 2002/12/07 18:10:13
@@ -575,6 +575,12 @@
* packet_game_info) should probably not be flexible, or at
* least need extra care to be flexible.
*/
+ GEN_INT("onsetwar", game.onsetwar, SSET_RULES_FLEXIBLE,
+ SSET_TO_CLIENT,
+ N_("War onset year"),
+ N_("No hostile actions possible before that year."), NULL,
+ GAME_MIN_ONSETWAR, GAME_MAX_ONSETWAR,
+ GAME_DEFAULT_ONSETWAR)
GEN_INT("barbarians", game.barbarianrate, SSET_RULES_FLEXIBLE,
SSET_TO_CLIENT,
N_("Barbarian appearance frequency"),
Index: server/unithand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.242
diff -u -r1.242 unithand.c
--- server/unithand.c 2002/11/14 09:15:05 1.242
+++ server/unithand.c 2002/12/07 18:10:14
@@ -976,6 +976,12 @@
return FALSE;
}
+ if (pcity && !onset_war_over(city_owner(pcity), unit_owner(punit))) {
+ notify_player_ex(pplayer, punit->x, punit->y, E_NOEVENT,
+ _("Game: Onset war not over"));
+ return FALSE;
+ }
+
if (pcity && !pplayers_at_war(city_owner(pcity), unit_owner(punit))) {
notify_player_ex(pplayer, punit->x, punit->y, E_NOEVENT,
_("Game: Can't attack %s's unit in the city of %s "
@@ -1003,6 +1009,14 @@
is a unit we have a treaty!=alliance with we can't move there */
pdefender = is_non_allied_unit_tile(pdesttile, unit_owner(punit));
if (pdefender) {
+ if (!onset_war_over(pplayer, unit_owner(pdefender))) {
+ notify_player_ex(pplayer, punit->x, punit->y, E_NOEVENT,
+ _("Game: Onset war not over"));
+ return FALSE;
+ }
+ }
+
+ if (pdefender) {
notify_player_ex(pplayer, punit->x, punit->y, E_NOEVENT,
_("Game: No war declared against %s, cannot attack."),
unit_owner(pdefender)->name);
@@ -1017,6 +1031,12 @@
notify_player_ex(pplayer, punit->x, punit->y, E_NOEVENT,
_("Game: Only ground troops can take over "
"a city."));
+ return FALSE;
+ }
+
+ if (!onset_war_over(city_owner(pcity), unit_owner(punit))) {
+ notify_player_ex(pplayer, punit->x, punit->y, E_NOEVENT,
+ _("Game: Onset war not over"));
return FALSE;
}
- [Freeciv-Dev] Re: (PR#2290) [rff] onsetwar,
Thomas Strub via RT <=
|
|