Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2005:
[Freeciv-Dev] (PR#13016) new trigger: turn-started
Home

[Freeciv-Dev] (PR#13016) new trigger: turn-started

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13016) new trigger: turn-started
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 9 May 2005 14:25:11 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13016 >

This patch adds a turn_started trigger (signal) to the codebase.  Also
attached is a scenario which uses this signal.  Unfortunately the
scenario doesn't work because scenario events don't work.

-jason

Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.259
diff -u -r1.259 srv_main.c
--- server/srv_main.c   7 May 2005 14:03:53 -0000       1.259
+++ server/srv_main.c   9 May 2005 21:23:15 -0000
@@ -480,6 +480,12 @@
   send_game_info(game.game_connections);
 
   if (is_new_turn) {
+    script_signal_emit("turn_started", 2,
+                      API_TYPE_INT, game.info.turn,
+                      API_TYPE_INT, game.info.year);
+  }
+
+  if (is_new_turn) {
     /* We build scores at the beginning of every turn.  We have to
      * build them at the beginning so that the AI can use the data,
      * and we are sure to have it when we need it. */
Index: server/scripting/script_signal.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/scripting/script_signal.c,v
retrieving revision 1.1
diff -u -r1.1 script_signal.c
--- server/scripting/script_signal.c    1 May 2005 12:01:16 -0000       1.1
+++ server/scripting/script_signal.c    9 May 2005 21:23:15 -0000
@@ -394,5 +394,6 @@
 **************************************************************************/
 static void signals_create(void)
 {
+  script_signal_create("turn_started", 2, API_TYPE_INT, API_TYPE_INT);
   script_signal_create("hut_enter", 1, API_TYPE_UNIT);
 }
[script]
code="
function my_callback(turn, year)
  notify.event(nil, nil, E.DIPLOMACY, _('New Turn %d, year %d!'), turn, year)
end

signal.connect('turn_started', 'my_callback')
print 'Loading scenario events.'
"

;code="print 'Hi'"

[game]
version=20099
server_state=0
metapatches=""
metatopic=""
metamessage=""
metaserver="http://meta.freeciv.org/metaserver.phtml";
gold=50
tech=0
skill_level=3
timeout=0
timeoutint=0
timeoutintinc=0
timeoutinc=0
timeoutincmult=1
timeoutcounter=1
info.timeoutaddenemymove=0
end_year=2000
year=-4000
turn=0
simultaneous_phases_now=0
simultaneous_phases_stored=1
researchcost=20
min_players=1
max_players=30
nplayers=0
heating=0
globalwarming=0
warminglevel=0
nuclearwinter=0
cooling=0
coolinglevel=0
notradesize=0
fulltradesize=1
unhappysize=4
angrycitizen=1
cityfactor=14
citymindist=0
civilwarsize=10
contactturns=20
rapturedelay=1
diplcost=0
freecost=0
conquercost=0
foodbox=10
techpenalty=100
razechance=20
civstyle=2
save_nturns=10
save_name="civgame"
aifill=0
scorelog=0
id=""
fogofwar=1
spacerace=1
auto_ai_toggle=0
diplchance=80
aqueductloss=0
killcitizen=1
turnblock=1
savepalace=1
fixedlength=0
barbarians=2
onsetbarbs=-2000
revolen=0
occupychance=0
autoattack=0
demography="NASRLPEMOqrb"
borders=7
happyborders=1
diplomacy=0
watchtower_vision=0
watchtower_extra_vision=2
allowed_city_names=1
settlers=2
explorer=1
start_units="ccwwx"
dispersion=0
randseed=0
save_random=0
rulesetdir="default"

[savefile]
options="startoptions spacerace2 rulesets diplchance_percent worklists2 
map_editor known32fix turn attributes watchtower rulesetdir client_worklists 
orders startunits turn_last_built improvement_order technology_order embassies"
reason="User request"
improvement_order="Airport", "Aqueduct", "Bank", "Barracks", "Barracks II", 
"Barracks III", "Cathedral", "City Walls", "Coastal Defense", "Colosseum", 
"Courthouse", "Factory", "Granary", "Harbour", "Hydro Plant", "Library", 
"Marketplace", "Mass Transit", "Mfg. Plant", "Nuclear Plant", "Offshore 
Platform", "Palace", "Police Station", "Port Facility", "Power Plant", 
"Recycling Center", "Research Lab", "SAM Battery", "SDI Defense", "Sewer 
System", "Space Component", "Space Module", "Space Structural", "Stock 
Exchange", "Super Highways", "Supermarket", "Temple", "University", "Apollo 
Program", "A.Smith's Trading Co.", "Colossus", "Copernicus' Observatory", "Cure 
For Cancer", "Darwin's Voyage", "Eiffel Tower", "Great Library", "Great Wall", 
"Hanging Gardens", "Hoover Dam", "Isaac Newton's College", "J.S. Bach's 
Cathedral", "King Richard's Crusade", "Leonardo's Workshop", "Lighthouse", 
"Magellan's Expedition", "Manhattan Project", "Marco Polo's Embassy", 
"Michelangelo's Chapel", "Oracle", "Pyramids", "SETI Program", "Shakespeare's 
Theatre", "Statue of Liberty", "Sun Tzu's War Academy", "United Nations", 
"Women's Suffrage", "Coinage"
technology_order="A_NONE", "Advanced Flight", "Alphabet", "Amphibious Warfare", 
"Astronomy", "Atomic Theory", "Automobile", "Banking", "Bridge Building", 
"Bronze Working", "Ceremonial Burial", "Chemistry", "Chivalry", "Code of Laws", 
"Combined Arms", "Combustion", "Communism", "Computers", "Conscription", 
"Construction", "Currency", "Democracy", "Economics", "Electricity", 
"Electronics", "Engineering", "Environmentalism", "Espionage", "Explosives", 
"Feudalism", "Flight", "Fundamentalism", "Fusion Power", "Genetic Engineering", 
"Guerilla Warfare", "Gunpowder", "Horseback Riding", "Industrialization", 
"Invention", "Iron Working", "Labor Union", "Laser", "Leadership", "Literacy", 
"Machine Tools", "Magnetism", "Map Making", "Masonry", "Mass Production", 
"Mathematics", "Medicine", "Metallurgy", "Miniaturization", "Mobile Warfare", 
"Monarchy", "Monotheism", "Mysticism", "Navigation", "Nuclear Fission", 
"Nuclear Power", "Philosophy", "Physics", "Plastics", "Polytheism", "Pottery", 
"Radio", "Railroad", "Recycling", "Refining", "Refrigeration", "Robotics", 
"Rocketry", "Sanitation", "Seafaring", "Space Flight", "Stealth", "Steam 
Engine", "Steel", "Superconductors", "Tactics", "The Corporation", "The 
Republic", "The Wheel", "Theology", "Theory of Gravity", "Trade", "University", 
"Warrior Code", "Writing"

[map]
mountains=30
grass=35
swampsize=5
deserts=5
riverlength=5
forestsize=20
topology_id=1
size=4
width=8
height=8
seed=0
landpercent=30
riches=250
wetness=50
steepness=30
huts=50
generator=1
have_huts=0
temperature=50
alltemperate=0
tinyisles=0
separatepoles=1

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13016) new trigger: turn-started, Jason Short <=