[Freeciv-Dev] (PR#13449) fix owner-pointer issues in scripts
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13449 >
This patch, I think, fixes the problems in scripts caused because
city:owner and unit:owner are pointers now. Previously there was an
owner_id value and city:owner() was a function that did a lookup.
However the tutorial scenario still doesn't work, and I have no idea how
to figure out why.
-jason
Index: data/scenario/tutorial.sav
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/scenario/tutorial.sav,v
retrieving revision 1.3
diff -p -u -r1.3 tutorial.sav
--- data/scenario/tutorial.sav 11 May 2005 14:57:09 -0000 1.3
+++ data/scenario/tutorial.sav 11 Jul 2005 18:48:15 -0000
@@ -13,12 +13,12 @@ end
signal.connect('turn_started', 'turn_callback')
function unit_moved_callback(unit, src_tile, dst_tile)
- if unit:owner():is_human() then
+ if unit:owner:is_human() then
if citiesbuilt == 0
and unit:type().name == 'Settlers'
and (dst_tile:terrain().name == 'Grassland'
or dst_tile:terrain().name == 'Plains') then
- notify.event(unit:owner(), dst_tile, E.TUTORIAL,
+ notify.event(unit:owner, dst_tile, E.TUTORIAL,
_('This looks like a good place to build a city. The next time this\\n\
unit gets a chance to move, press (b) to found a city.\\n\
\\n\
@@ -31,9 +31,9 @@ end
signal.connect('unit_moved', 'unit_moved_callback')
function city_built_callback(city)
- if city:owner():is_human() then
+ if city:owner:is_human() then
if citiesbuilt == 0 then
- notify.event(city:owner(), city.tile, E.TUTORIAL,
+ notify.event(city:owner, city.tile, E.TUTORIAL,
_('Now you have built your first city. The city window should have\\n\
opened automatically; if not click on the city to open it. Cities are\\n\
a fundamental concept in Freeciv, so you should familiarize yourself\\n\
@@ -46,13 +46,13 @@ Change button to begin building it. Whe
dialog. If all goes well the city should display the settler\\n\
production on the map view.'))
elseif citiesbuilt == 1 then
- notify.event(city:owner(), city.tile, E.TUTORIAL,
+ notify.event(city:owner, city.tile, E.TUTORIAL,
_('Congratulations, you have founded your second city. This city will\\n\
behave almost exactly like the first one - it will be slightly different\\n\
because of the terrain around it. You probably want to build\\n\
settlers here too.'))
elseif citiesbuilt == 2 then
- notify.event(city:owner(), city.tile, E.TUTORIAL,
+ notify.event(city:owner, city.tile, E.TUTORIAL,
_('You have built your third city! Your civilization seems to be\\n\
thriving. It might be time to think about a military. Pick one of\\n\
the cities that has a high production, and convert it into a military\\n\
@@ -67,7 +67,7 @@ to begin building them. Then double-cli
append it to the worklist. As soon as the Barracks are complete the\\n\
city will automatically switch over to producing the unit.'))
elseif citiesbuilt == 3 then
- notify.event(city:owner(), city.tile, E.TUTORIAL,
+ notify.event(city:owner, city.tile, E.TUTORIAL,
_('Another city! You are really getting the hang of this. You\\n\
probably have a pretty good idea what to do with new cities by\\n\
now. Take a moment to look at the bar below the city on the map\\n\
@@ -80,7 +80,7 @@ city. The bottom row shows what the cit
will take; it also shows how long the city will take to grow to the\\n\
next largest size.'))
elseif citiesbuilt == 4 then
- notify.event(city:owner(), city.tile, E.TUTORIAL,
+ notify.event(city:owner, city.tile, E.TUTORIAL,
_('As the number of cities in your empire grows, it becomes harder to\\n\
manage individual cities. This is where the city report becomes\\n\
useful. Press F1 to bring it up. This report shows a list of cities\\n\
@@ -97,9 +97,9 @@ citiesbuilt = 0
signal.connect('city_built', 'city_built_callback')
function city_growth_callback(city, size)
- if city:owner():is_human() then
+ if city:owner:is_human() then
if size == 2 and not growth2msg then
- notify.event(city:owner(), city.tile, E.TUTORIAL,
+ notify.event(city:owner, city.tile, E.TUTORIAL,
_('Your city has grown! As a city grows, more citizens become\\n\
available that can be put to work in the fields or dedicated as\\n\
citizen specialists. A city of size two or more may also build\\n\
@@ -111,7 +111,7 @@ in gold (if you have enough of it) to in
production.'))
growth2msg = true
elseif size == 3 and not growth3msg then
- notify.event(city:owner(), city.tile, E.TUTORIAL,
+ notify.event(city:owner, city.tile, E.TUTORIAL,
_('Your city has grown again! Now with three citizens you have\\n\
a fair amount of choice over where the city should focus its\\n\
resources. A city with three citizens gets to work three\\n\
@@ -129,7 +129,7 @@ specialists - right now they are all ent
only luxuries (which will not be useful until later).'))
growth3msg = true
elseif size == 5 and not growth5msg then
- notify.event(city:owner(), city.tile, E.TUTORIAL,
+ notify.event(city:owner, city.tile, E.TUTORIAL,
_('Now your city has grown to size five. As cities get larger unrest\\n\
becomes a problem. A city of this size will usually have one unhappy\\n\
citizen unless pacifying effects are used; meaning one entertainer\\n\
@@ -146,7 +146,7 @@ citizen). Building a marketplace enhanc
by providing +50% luxuries to the city.'))
growth5msg = true
elseif size == 8 and not growth8msg then
- notify.event(city:owner(), city.tile, E.TUTORIAL,
+ notify.event(city:owner, city.tile, E.TUTORIAL,
_('Finally you have grown a city to size eight. A size eight city can\\n\
provide substantial output provided you have enough luxuries to keep\\n\
your population content.\\n\
@@ -156,13 +156,13 @@ going to continue to grow you should sta
an aqueduct requires the Construction technology.'))
growth8msg = true
elseif size == 12 and not growth12msg then
- notify.event(city:owner(), city.tile, E.TUTORIAL,
+ notify.event(city:owner, city.tile, E.TUTORIAL,
_('You have grown a city to size twelve. To grow\\n\
it larger, however, you will need to build a Sewer System. This\\n\
requires the Sanitation technology.'))
growth12msg = true
elseif size == 13 and not growth13msg then
- notify.event(city:owner(), city.tile, E.TUTURIAL,
+ notify.event(city:owner, city.tile, E.TUTURIAL,
_('Congratulations; you have grown a city to size 13. A city this\\n\
large can provide a tremendous amount of output if properly upgraded.\\n\
Make sure you have enough taxes and cultural buildings to keep your\\n\
@@ -187,12 +187,12 @@ growth13msg = false
signal.connect('city_growth', 'city_growth_callback')
function unit_built_callback(unit)
- if not unit:owner():is_human() then
+ if not unit:owner:is_human() then
return
end
if unit:type().name == 'Settlers' then
if settlersbuilt == 0 then
- notify.event(unit:owner(), unit.tile, E.TUTORIAL,
+ notify.event(unit:owner, unit.tile, E.TUTORIAL,
_('You have built a settler unit. Settlers are best used to build \\n\
new cities, so as to expand your civilization. Move your settler\\n\
away from your existing cities to find a spot for a new city. When\\n\
@@ -206,7 +206,7 @@ tundra, and mountains generally provide
of much use to small cities. See the help on terrain and specials\\n\
for more information about terrain specs.'))
elseif settlersbuilt == 1 then
- notify.event(unit:owner(), unit.tile, E.TUTORIAL,
+ notify.event(unit:owner, unit.tile, E.TUTORIAL,
_('Your second Settlers should also be used to build a new city.\\n\
Notice how when you move the Settlers away from your existing cities\\n\
an outline is drawn around them. This shows the area that would be\\n\
@@ -225,11 +225,11 @@ settlersbuilt = 0
signal.connect('unit_built', 'unit_built_callback')
function building_built_callback(building, city)
- if not city:owner():is_human() then
+ if not city:owner:is_human() then
return
end
if building.name == 'Barracks' and not barracksmsg then
- notify.event(city:owner(), city.tile, E.TUTORIAL,
+ notify.event(city:owner, city.tile, E.TUTORIAL,
_('You have built a Barracks. This building will make any military\\n\
units you build start out as veterans. Veteran units are stronger\\n\
than inexperienced (green) troops, and will survive longer in\\n\
@@ -247,11 +247,11 @@ barracksmsg = false
signal.connect('building_built', 'building_built_callback')
function unit_cant_be_built_callback(unittype, city, reason)
- if not city:owner():is_human() then
+ if not city:owner:is_human() then
return
end
if unittype.name == 'Settlers' and not nosettlermsg then
- notify.event(city:owner(), city.tile, E.TUTORIAL,
+ notify.event(city:owner, city.tile, E.TUTORIAL,
_('Your city cannot build a settler. Settlers take one unit of\\n\
population to build, so a city of size one cannot build one without\\n\
disbanding the city.\\n\
@@ -263,7 +263,7 @@ founding a new city, make sure it is bui
enough food - grassland is best; plains or hills are almost as good.'))
nosettlermsg = true
elseif not unittype:has_flag('NonMil') and not nomilmsg then
-notify.event(city:owner(), city.tile, E.TUTORIAL,
+notify.event(city:owner, city.tile, E.TUTORIAL,
_('You have built your first military unit! Military units have two\\n\
basic purposes: attack and defense. Each unit has an attack strength\\n\
and a defense strength. While a Warriors is a measly 1/1, a Phalanx\\n\
@@ -345,11 +345,11 @@ numtechs = 0
signal.connect('tech_researched', 'tech_researched_callback')
function hut_entered_callback(unit)
- if not unit:owner():is_human() then
+ if not unit:owner:is_human() then
return
end
if not hutmsg then
- notify.event(unit:owner(), unit.tile, E.TUTORIAL,
+ notify.event(unit:owner, unit.tile, E.TUTORIAL,
_('Your unit has found a Hut. These are small villages scattered across\\n\
the landscape. When a unit enters one several things may happen. The\\n\
most likely outcome is that you will find resources worth a small\\n\
Index: server/scripting/api.pkg
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/scripting/api.pkg,v
retrieving revision 1.10
diff -p -u -r1.10 api.pkg
--- server/scripting/api.pkg 4 Jul 2005 17:48:38 -0000 1.10
+++ server/scripting/api.pkg 11 Jul 2005 18:48:15 -0000
@@ -143,20 +143,11 @@ function Player:num_units()
return methods_player_num_units(self)
end
--- City methods.
-function City:owner()
- return find.player(self.owner_id)
-end
-
-- Unit methods.
function Unit:type()
return find.unit_type(self.type_id)
end
-function Unit:owner()
- return find.player(self.owner_id)
-end
-
function Unit:homecity()
return find.city(self:owner(), self.homecity_id)
end
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#13449) fix owner-pointer issues in scripts,
Jason Short <=
|
|