• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

trying to use a minimalist mod to do big things

okay, so CyCity is a city

methods are functions associated with them like building and razing and population growth

CyCity() is an actual city with production and citizens and food and all the things that makes a city on the map a city

I'm missing exactly what the point of pCity = CyCity() is other than to save you typing

so pCity.setName() is to use the setName() function of CyCity() (we're using pCity as code for that here)

Am I on target so far?

so I could also say pCity.razeCity() (or a command to that effect...I'm just making something up here) to destroy the city instead of naming it? Something like pCity.growCity() might be used to increase the population by one, or fill the granary, or however we defined growCity() with a def line elsewhere?

so a CyPlayer instance is something a game player can do, like build a city. Having defined pPlayer as shorthand for CyPlayer we can say pPlayer.initCity(x, y) to literally "build" a city in the game for the active player at the stated coords? Or will it simply do whatever we tell it to do next to the city at those coords?

lemmie read your next post (#40) and see if I understand that one, while you tell me whether I'm a genius or a dunce for this one, lol
 
alright...I think I understand #40 as well, and will be giving it a harder look at stage two of this mod (scripting the "spawns" [units and culture changes] triggered by game years)...but I'll wait to see what you have to say about my attempt to restate your lesson points before moving on in a totally wrong direction
 
I'm missing exactly what the point of pCity = CyCity() is other than to save you typing
CyCity() is a "class constructor" that creates a new instance of the class. Most of the time you wanna keep a reference to whatever class you create, so this is what the variable assignment is for. Because otherwise you'd be creating a new instance (a new city in this example) each time you invoke a method - and this is seldom what you want. You wanna keep track of all the game objects and do things to them - not just create new ones.

so pCity.setName() is to use the setName() function of CyCity() (we're using pCity as code for that here)

Am I on target so far?
You seem to be. :goodjob:

so I could also say pCity.razeCity() (or a command to that effect...I'm just making something up here) to destroy the city instead of naming it? Something like pCity.growCity() might be used to increase the population by one, or fill the granary, or however we defined growCity() with a def line elsewhere?
Yeah, just look the CyCity class up in the API! There are literately hundreds of methods defined to be used with each of these major classes! This is your toolbox - learn how to use it.

so a CyPlayer instance is something a game player can do, like build a city. Having defined pPlayer as shorthand for CyPlayer we can say pPlayer.initCity(x, y) to literally "build" a city in the game for the active player at the stated coords? Or will it simply do whatever we tell it to do next to the city at those coords?
Almost correct. A CyPlayer instance is the actual "player". You know, those things you define at the beginning of the WBS file. They are enumerated from zero and up and assigned a Civilization type. So its important to know what CyPlayer instance corresponds to what enumerated player - and this is what the ID values are for. This is how the game keeps track of the objects it creates - just as you'd wanna assign any objects you create yourself to variables of some sort.

lemmie read your next post (#40) and see if I understand that one, while you tell me whether I'm a genius or a dunce for this one, lol
No, you're definately getting there. I'm only writing this up for you because I truly believe you when you say that you're reading the sources also. Because otherwise I would have to post everything they contain - and that simply isn't possible to do. (Although I'd love to write a comprehensive CivIV modding guide sometime in the future. Python as a modding tool only. In another life, maybe? :rolleyes:)
 
"Almost correct. A CyPlayer instance is the actual "player". You know, those things you define at the beginning of the WBS file. "

that is what I meant, but expressed poorly, above.
 
I'm still getting a syntax error on the def line in dawnoftime ...I'm sure it's something mad simple, but it eludes me...

...back to the textbook...
 
I altered the indentation, but I guess I still have it wrong. Here's what the log says:

File "DawnOfTime", line 272
def nameNorm(pCity):
^
SyntaxError: invalid syntax
load_module CvAppInterface
 
Ok, so you know about the different player/Civ values from the RFC mod:
Code:
iRome = 7
pRome = gc.getPlayer(iRome)
teamRome = gc.getTeam(pRome.getTeam())
There actually is no such thing as independent "Civilizations" in CivIV. Instead there are "players". These would be CyPlayer instances. The associated Civ is only an attribute of that player - and several players can have the same attributes.

So the iRome variable is referencing the integer value 7 - here corresponding to the eight enumerated CvPlayer instance in the SDK - corresponding to the seventh CyPlayer instance within the context of CivIV Python. But its still "only" the number seven - it could as well be used for the eight building type, the eight promotion or whatever. Or in a mathematical calculation where iRome is still the number 7.

The naming iRome is just for convenience because each Civ is only used once for players in RFC. But it would be both confusing and invalid in a mod/game where two players share the same Civ. :eek:

The pRome value is fetched with the CyGlobalContext.getPlayer() method and takes the index number stored in iRome as an "argument" (also called a "parameter" with class methods). This is a reference to the actual CyPlayer instance, which in turn affects the original CvPlayer instance in the C++ code.

Then there are teams. :rolleyes: Well, every CyPlayer instance must be associated with a CyTeam instance, this is just how the game is designed. (I guess several CyPlayer objects can share the same CyTeam object - even if they never do in RFC.) The CyTeam instance is needed for accessing methods that have to do with Techs and Diplomacy and other team related stuff. The method for fetching the instance is CyGlobalContext.getTeam() and it takes a... team ID value as its parameter. :crazyeye:

This is a bit confusing, but try to keep up. So all the CyTeam instances are also enumerated from zero and up. In RFC they happen to match up perfectly with the CyPlayer index numbers, so this extra detour isn't really necessary. But if we wanna do things proper, then the getTeam() method takes a team ID (integer). That in turn can be fetched with CyPlayer.getTeam(). This took me awhile to figure out, so you might just wanna keep this information handy for once you need it... :p
 
I altered the indentation, but I guess I still have it wrong. Here's what the log says:

File "DawnOfTime", line 272
def nameNorm(pCity):
^
SyntaxError: invalid syntax
load_module CvAppInterface
Whenever the ^ thingy points at the beginning of the line with a syntax error the problem is usually the line before. Because something is missing there, making the interpreter misunderstand the whole script. So it basically thinks that there is a problem on the definition line, while there really isn't. Please post the entire script for proofreading.
 
Spoiler :
Code:
from CvPythonExtension import *
from PyHelpers import *
from Popup import PyPopup
from CvEventManager import *

gc = CyGlobalContext()
cyGame = CyGame()
cyMap = CyMap()
pyGame = PyGame()
pCity = pPlayer.initCity(x, y)


cityNameDict = {
(55, 54): "London",
(55, 53): "London",
(56, 53): "London",
(56, 54): "London",
(63, 52): "Berlin",
(62, 52): "Berlin",
(62, 53): "Berlin",
(63, 53): "Berlin",
(51, 55): "Dublin",
(51, 56): "Dublin",
(55, 58): "Edinburgh",
(54, 57): "Edinburgh",
(54, 58): "Edinburgh",
(58, 51): "Paris",
(59, 51): "Paris",
(58, 52): "Paris",
(57, 51): "Paris",
(58, 50): "Paris",
(57, 50): "Paris",
(55, 45): "Madrid",
(55, 46): "Madrid",
(54, 46): "Madrid",
(54, 45): "Madrid",
(53, 45): "Lisbon",
(53, 44): "Lisbon",
(53, 46): "Lisbon",
(61, 46): "Rome",
(62, 45): "Rome",
(62, 46): "Rome",
(61, 47): "Rome",
(60, 47): "Rome",
(67, 43): "Athens",
(66, 42): "Athens",
(67, 44): "Athens",
(66, 44): "Athens",
(68, 46): "Byzantium",
(67, 46): "Byzantium",
(69, 45): "Byzantium",
(73, 40): "Jerusalem",
(73, 41): "Jerusalem",
(72, 40): "Jerusalem",
(73, 42): "Antioch",
(73, 43): "Antioch",
(68, 39): "Alexandria",
(69, 39): "Alexandria",
(67, 39): "Alexandria",
(30, 47): "New York",
(31, 47): "New York",
(29, 47): "New York",
(29, 46): "New York",
(31, 48): "Boston",
(31, 49): "Boston",
(32, 49): "Boston",
(24, 43): "New Orleans",
(23, 43): "New Orleans",
(25, 43): "New Orleans",
(24, 48): "Chicago",
(24, 47): "Chicago",
(24, 49): "Chicago",
(25, 47): "Chicago",
(12, 48): "San Francisco",
(12, 47): "San Francisco",
(12, 49): "San Francisco",
(12, 50): "Seattle",
(12, 46): "Los Angeles",
(75, 35): "Mecca",
(74, 36): "Mecca",
(75, 34): "Mecca",
(74, 37): "Mecca",
(73, 37): "Mecca",
(76, 34): "Mecca",
(68, 57): "St. Petersburg",
(67, 56): "St. Petersburg",
(66, 56): "St. Petersburg",
(68, 56): "St. Petersburg",
(68, 58): "St. Petersburg",
(67, 58): "St. Petersburg",
(71, 54): "Moscow",
(71, 53): "Moscow",
(70, 53): "Moscow",
(72, 53): "Moscow",
(72, 54): "Moscow",
(70, 54): "Moscow",
(70, 56): "Moscow",
(71, 55): "Moscow",
(72, 55): "Moscow",
(69, 52): "Kiev",
(69, 51): "Kiev",
(70, 51): "Kiev",
(70, 50): "Odessa",
(71, 50): "Odessa",
(89, 35): "Bombay",
(89, 34): "Bombay",
(88, 35): "Bombay",
(88, 36): "Bombay",
(92, 34): "Pondicherry",
(91, 34): "Pondicherry",
(91, 33): "Pondicherry",
(102, 47): "Peking",
(101, 48): "Peking",
(102, 48): "Peking",
(103, 48): "Peking",
(101, 47): "Peking",
(103, 47): "Peking",
(101, 46): "Peking",
(102, 46): "Peking",
(103, 46): "Peking",
(115, 46): "Tokyo",
(115, 45): "Tokyo",
(114, 44): "Tokyo",
(106, 43): "Shanghai",
(106, 44): "Shanghai",
(106, 45): "Shanghai",
(107, 43): "Shanghai",
(107, 42): "Shanghai",
(105, 39): "Canton",
(105, 40): "Canton",
(106, 40): "Canton",
(106, 41): "Canton",
(103, 38): "Hong Kong",
(103, 39): "Hong Kong",
(104, 39): "Hong Kong",
(102, 38): "Hong Kong",
(102, 32): "Saigon",
(103, 33): "Saigon",
(102, 33): "Saigon",
(1, 38): "Honolulu",
(3, 37): "Honolulu",
(4, 35): "Hilo",
(5, 36): "Hilo",
(103, 14): "Perth",
(104, 14): "Perth",
(104, 13): "Perth",
(104, 12): "Perth",
(103, 12): "Perth",
(107, 19): "Darwin",
(107, 20): "Darwin",
(108, 20): "Darwin",
(108, 21): "Darwin",
(118, 13): "Sydney",
(117, 12): "Sydney",
(118, 15): "Sydney",
(118, 16): "Sydney",
(118, 17): "Sydney",
(114, 10): "Adelaide",
(114, 11): "Adelaide",
(113, 11): "Adelaide",
(115, 10): "Adelaide",
(77, 41): "Babylon",
(77, 40): "Babylon",
(76, 41): "Babylon",
(77, 42): "Babylon",
(76, 42): "Babylon",
(58, 47): "Marseilles",
(58, 48): "Marseilles",
(59, 48): "Marseilles",
(56, 48): "Bordeaux",
(56, 49): "Bordeaux",
(55, 51): "Brest",
(56, 51): "Brest",
(56, 44): "Gibraltar",
(54, 44): "Gibraltar",
(53, 54): "Cardiff",
(54, 54): "Cardiff",
(53, 55): "Cardiff",
(53, 53): "Cardiff",
(55, 56): "York",
(54, 56): "York",
(49, 54): "Cork",
(49, 56): "Galway",
(50, 56): "Galway",
(51, 54): "Waterford",
(50, 54): "Cashel",
(51, 57): "Belfast",
(50, 57): "Derry",
(50, 55): "Limerick",
(60, 55): "Copenhagen",
(60, 54): "Copenhagen",
(60, 53): "Copenhagen",
(62, 52): "Trondheim",
(63, 63): "Trondheim",
(64, 64): "Trondheim",
(60, 58): "Oslo",
(59, 57): "Oslo",
(58, 58): "Oslo",
(62, 58): "Uppsala",
(62, 59): "Uppsala",
(62, 60): "Uppsala",
(63, 58): "Stockholm",
(63, 57): "Stockholm",
(63, 56): "Stockholm",
(62, 56): "Stockholm",
(66, 59): "Helsinki",
(65, 59): "Helsinki",
(65, 58): "Helsinki",
(65, 58): "Vilnius",
(65, 55): "Vilnius",
(66, 54): "Vilnius",
(66, 55): "Vilnius",
(64, 53): "Vilnius",
(65, 53): "Vilnius",
(66, 53): "Vilnius",
(63, 50): "Vienna",
(64, 50): "Vienna",
(65, 50): "Vienna",
(65, 49): "Vienna",
(64, 49): "Vienna",
(63, 49): "Vienna",
(64, 52): "Warsaw",
(63, 51): "Warsaw",
(62, 48): "Venice",
(61, 48): "Venice",
(63, 48): "Venice",
(61, 43): "Palermo",
(62, 43): "Palermo",
(76, 32): "Sanaa",
(77, 32): "Sanaa",
(77, 33): "Sanaa",
(78, 33): "Sanaa",
(64, 12): "Cape Town",
(64, 13): "Cape Town",
(65, 13): "Cape Town",
(65, 12): "Cape Town",
(42, 18): "Rio De Janeiro",
(43, 19): "Rio De Janeiro",
(41, 18): "Rio De Janeiro",
(39, 15): "Montevideo",
(38, 14): "Montevideo",
(38, 13): "Montevideo",
(36, 13): "Buenos Aires",
(37, 13): "Buenos Aires",
(36, 12): "Buenos Aires",
(18, 39): "Mexico City",
(18, 38): "Mexico City",
(19, 39): "Mexico City",
(19, 40): "Mexico City",
(18, 49): "Mexico City",
(24, 45): "St. Louis",
(25, 45): "St. Louis",
(25, 46): "St. Louis",
(24, 46): "St. Louis",
(27, 38): "Havanna",
(28, 38): "Havanna",
(31, 37): "Port-au-Prince",
(31, 39): "Port-au-Prince",
(56, 50): "Nantes",
(59, 53): "Amsterdam",
(59, 52): "Amsterdam",
(28, 46): "Philadelphia",
(28, 45): "Philadelphia",
(27, 45): "Washington",
(27, 44): "Washington",
(96, 39): "Calcutta",
}




    def nameNorm(pCity):
        coord = (pCity.getX(), pCity.getY())
        if coord in cityNameDict:
            name = cityNameDict[coord]
            pCity.setName(name)

should I be ending the dictionary with a colon (preceeding the indent)?
 
Ah, you're still one indentation level up with your function definition:
Code:
def nameNorm(pCity):
   coord = (pCity.getX(), pCity.getY())
   if coord in cityNameDict:
      name = cityNameDict[coord]
      pCity.setName(name)
As I said before, the first indentation level is exactly zero amount of white space. This is where all code starts off - at the beginning. The first new block of code comes after the function definition line, and the next one after the conditional statement (if statement).
 
...so I'm guessing you're picking things up from other people's modules, rather than from the textbook then? :rolleyes:
 
Just as trivia, your function could be defined like this also:
Code:
def nameNorm(pCity):
   coord = (pCity.getX(), pCity.getY())
   name = cityNameDict.get(coord, "")
   if name != "":
      pCity.setName(name)
And it could be shortened to just:
Code:
def nameNorm(pCity):
   name = cityNameDict.get((pCity.getX(), pCity.getY()), "")
   if name:
      pCity.setName(name)
Sorry about that, I just can't help myself. :p
 
Three things:

I altered the indentation, but I guess I still have it wrong. Here's what the log says:

File "DawnOfTime", line 272
def nameNorm(pCity):
^
SyntaxError: invalid syntax
load_module CvAppInterface

First, the "def" should have no indentation whatsoever. If it still has some, unindent it.

Second, the problem may be with the extraneous comma at the end of your dictionary here:
Code:
(96, 39): "Calcutta",
}
There is no additional entry after that so you should not have a comma.

Third, if you do this:
Code:
	def onCityBuilt(self, argsList):
		'City Built'
		city = argsList[0]
		if (city.getOwner() == gc.getGame().getActivePlayer()):
			self.__eventEditCityNameBegin(city, False)	
		CvUtil.pyPrint('City Built Event: %s' %(city.getName()))
		DawnOfTime.nameNorm(city)
what you will see is that when the human player founds a new city it will pop up the dialog asking what they want the name to be (with the default already in the box) as usual. But then it will change the name out from under them if it finds a new name in your dictionary. Asking the player what they want the city to be named and then sometimes naming it something else no matter what they say is not a good user interface design. (Putting it after the CvUtil.pyPrint also causes it to log the wrong city name, by the way.)

To avoid this, I suggest that you should either
A) set the name before the "if" block that asks the player what they want the city to be named shows up (which ought to put the defined name into the name filed as the default), which also gets all of the naming stuff done before the logging of the name too.
or
B) have your nameNorm function return a boolean value - True if it changed the name, False if it did not. Then do something more like this:
Code:
	def onCityBuilt(self, argsList):
		'City Built'
		city = argsList[0]
		bChanged = DawnOfTime.nameNorm(city)
		if ((not bChanged) and (city.getOwner() == gc.getGame().getActivePlayer()):
			self.__eventEditCityNameBegin(city, False)	
		CvUtil.pyPrint('City Built Event: %s' %(city.getName()))
Option B doesn't even ask the player what they want the city to be named if there is a name for it in the dictionary, it just gives it the name from your dictionary.

A is friendlier, but if you really want to force the historical names then B will do that (although a player can still change the name later from the city screen).
 
Yeah, all good points God-Emperor. :goodjob:

This is how you would go about adding a return value to the function, by the way:
Code:
def nameNorm(pCity):
   coord = (pCity.getX(), pCity.getY())
   if coord in cityNameDict:
      name = cityNameDict[coord]
      pCity.setName(name)
      return True
   else:
      return False
(The last two lines aren't entirely necessary as they add no additional functionality. But you might as well learn how this works the proper way.)

How exactly return values work is of course described in the textbook and also in the tutorials.
 
well, I only removed one indentation level (instead of dropping to zero indentation) because that was your earlier suggestion...I suppose what I had as two looked like one...etc...crossed wires. I actually thought that it should start off with zero indent, but second guessed myself.

I didn't get that from another mod, but it did start with a suggestion in this thread.

ah, the comma was due to a macro of sorts I used when putting together the list.

OHOHOH...I actually thought there was a problem putting the dawnoftime line after cvutil.pyprint but (again) second guessed myself when Baldyr said to stick it there. I figured it had to go earlier in the code, but wasn't sure precisely where (I would have been wrong anyway, but it would have been a principled wrong!)

and I did read about the returns...I can substitute 0,1 for False,True, no?
 
OHOHOH...I actually thought there was a problem putting the dawnoftime line after cvutil.pyprint but (again) second guessed myself when Baldyr said to stick it there. I figured it had to go earlier in the code, but wasn't sure precisely where (I would have been wrong anyway, but it would have been a principled wrong!)
There you go then. I've actually never dealt with the default CvEventManager's onCityBuilt() call so I didn't recognize the code initiating the city name popup... I'm severely handicapped from only doing mod-modding. :p

and I did read about the returns...I can substitute 0,1 for False,True, no?
Yeah, sure. But I don't see why you would wanna do that. If you have a reason for doing so - go for it. Otherwise it may cause confusion down the line... (Because sometime you might wanna return actual integer values - and not have them replace True/False.)

I trust that you're mod is working now? :king:
 
and I did read about the returns...I can substitute 0,1 for False,True, no?

You can, but I wouldn't. If it is supposed to be a True/False value then use True or False. This makes what is going on a lot clearer. It also avoids the issue of having to remember what various different languages use for the equivalent of true and false values (in Python, 0 is not the only thing that can represent a False value: any empty list, empty set, empty dictionary, empty string, the None value, and probably more stuff are also all equivalent to False and anything that isn't equivalent to false is equivalent to true; in other languages you get a situation where the integer 0 is actually an equivalent of true, like in Ruby where only a null object and the specifically defined "false object" are false and everything else, including the integer 0, is considered to be true; then there's SQL in which there are not just two boolean values, there are 4 : true, false, undefined, and something else that I can't remember - maybe "nothing" or "null" - and what integer values these 4 are equivalent to, if any, is something I don't know).
 
hm...I've also gone ahead and defined pPlayer ...but now it's telling me it can't find CvPythonExtensions for the import. As it's line 1, why did it not flag that problem before?
 
hm...I've also gone ahead and defined pPlayer ...but now it's telling me it can't find CvPythonExtensions for the import. As it's line 1, why did it not flag that problem before?
Hmm... What are you using pPlayer for, might I ask?

The import issue sounds... weird. What is the actual exception and how does your script look like as of now?

edit: I guess CvPythonExtensions is actually defined in the SDK, and since you haven't done anything with that then this should be away if you reload/restart the mod/game?
 
Spoiler :
Code:
from CvPythonExtension import *
from PyHelpers import *
from Popup import PyPopup
from CvEventManager import *

gc = CyGlobalContext()
cyGame = CyGame()
cyMap = CyMap()
pyGame = PyGame()
pCity = pPlayer.initCity(x, y)
pPlayer = gc.getActivePlayer()


cityNameDict = {
(55, 54): "London",
(55, 53): "London",
(56, 53): "London",
(56, 54): "London",
(63, 52): "Berlin",
(62, 52): "Berlin",
(62, 53): "Berlin",
(63, 53): "Berlin",
(51, 55): "Dublin",
(51, 56): "Dublin",
(55, 58): "Edinburgh",
(54, 57): "Edinburgh",
(54, 58): "Edinburgh",
(58, 51): "Paris",
(59, 51): "Paris",
(58, 52): "Paris",
(57, 51): "Paris",
(58, 50): "Paris",
(57, 50): "Paris",
(55, 45): "Madrid",
(55, 46): "Madrid",
(54, 46): "Madrid",
(54, 45): "Madrid",
(53, 45): "Lisbon",
(53, 44): "Lisbon",
(53, 46): "Lisbon",
(61, 46): "Rome",
(62, 45): "Rome",
(62, 46): "Rome",
(61, 47): "Rome",
(60, 47): "Rome",
(67, 43): "Athens",
(66, 42): "Athens",
(67, 44): "Athens",
(66, 44): "Athens",
(68, 46): "Byzantium",
(67, 46): "Byzantium",
(69, 45): "Byzantium",
(73, 40): "Jerusalem",
(73, 41): "Jerusalem",
(72, 40): "Jerusalem",
(73, 42): "Antioch",
(73, 43): "Antioch",
(68, 39): "Alexandria",
(69, 39): "Alexandria",
(67, 39): "Alexandria",
(30, 47): "New York",
(31, 47): "New York",
(29, 47): "New York",
(29, 46): "New York",
(31, 48): "Boston",
(31, 49): "Boston",
(32, 49): "Boston",
(24, 43): "New Orleans",
(23, 43): "New Orleans",
(25, 43): "New Orleans",
(24, 48): "Chicago",
(24, 47): "Chicago",
(24, 49): "Chicago",
(25, 47): "Chicago",
(12, 48): "San Francisco",
(12, 47): "San Francisco",
(12, 49): "San Francisco",
(12, 50): "Seattle",
(12, 46): "Los Angeles",
(75, 35): "Mecca",
(74, 36): "Mecca",
(75, 34): "Mecca",
(74, 37): "Mecca",
(73, 37): "Mecca",
(76, 34): "Mecca",
(68, 57): "St. Petersburg",
(67, 56): "St. Petersburg",
(66, 56): "St. Petersburg",
(68, 56): "St. Petersburg",
(68, 58): "St. Petersburg",
(67, 58): "St. Petersburg",
(71, 54): "Moscow",
(71, 53): "Moscow",
(70, 53): "Moscow",
(72, 53): "Moscow",
(72, 54): "Moscow",
(70, 54): "Moscow",
(70, 56): "Moscow",
(71, 55): "Moscow",
(72, 55): "Moscow",
(69, 52): "Kiev",
(69, 51): "Kiev",
(70, 51): "Kiev",
(70, 50): "Odessa",
(71, 50): "Odessa",
(89, 35): "Bombay",
(89, 34): "Bombay",
(88, 35): "Bombay",
(88, 36): "Bombay",
(92, 34): "Pondicherry",
(91, 34): "Pondicherry",
(91, 33): "Pondicherry",
(102, 47): "Peking",
(101, 48): "Peking",
(102, 48): "Peking",
(103, 48): "Peking",
(101, 47): "Peking",
(103, 47): "Peking",
(101, 46): "Peking",
(102, 46): "Peking",
(103, 46): "Peking",
(115, 46): "Tokyo",
(115, 45): "Tokyo",
(114, 44): "Tokyo",
(106, 43): "Shanghai",
(106, 44): "Shanghai",
(106, 45): "Shanghai",
(107, 43): "Shanghai",
(107, 42): "Shanghai",
(105, 39): "Canton",
(105, 40): "Canton",
(106, 40): "Canton",
(106, 41): "Canton",
(103, 38): "Hong Kong",
(103, 39): "Hong Kong",
(104, 39): "Hong Kong",
(102, 38): "Hong Kong",
(102, 32): "Saigon",
(103, 33): "Saigon",
(102, 33): "Saigon",
(1, 38): "Honolulu",
(3, 37): "Honolulu",
(4, 35): "Hilo",
(5, 36): "Hilo",
(103, 14): "Perth",
(104, 14): "Perth",
(104, 13): "Perth",
(104, 12): "Perth",
(103, 12): "Perth",
(107, 19): "Darwin",
(107, 20): "Darwin",
(108, 20): "Darwin",
(108, 21): "Darwin",
(118, 13): "Sydney",
(117, 12): "Sydney",
(118, 15): "Sydney",
(118, 16): "Sydney",
(118, 17): "Sydney",
(114, 10): "Adelaide",
(114, 11): "Adelaide",
(113, 11): "Adelaide",
(115, 10): "Adelaide",
(77, 41): "Babylon",
(77, 40): "Babylon",
(76, 41): "Babylon",
(77, 42): "Babylon",
(76, 42): "Babylon",
(58, 47): "Marseilles",
(58, 48): "Marseilles",
(59, 48): "Marseilles",
(56, 48): "Bordeaux",
(56, 49): "Bordeaux",
(55, 51): "Brest",
(56, 51): "Brest",
(56, 44): "Gibraltar",
(54, 44): "Gibraltar",
(53, 54): "Cardiff",
(54, 54): "Cardiff",
(53, 55): "Cardiff",
(53, 53): "Cardiff",
(55, 56): "York",
(54, 56): "York",
(49, 54): "Cork",
(49, 56): "Galway",
(50, 56): "Galway",
(51, 54): "Waterford",
(50, 54): "Cashel",
(51, 57): "Belfast",
(50, 57): "Derry",
(50, 55): "Limerick",
(60, 55): "Copenhagen",
(60, 54): "Copenhagen",
(60, 53): "Copenhagen",
(62, 52): "Trondheim",
(63, 63): "Trondheim",
(64, 64): "Trondheim",
(60, 58): "Oslo",
(59, 57): "Oslo",
(58, 58): "Oslo",
(62, 58): "Uppsala",
(62, 59): "Uppsala",
(62, 60): "Uppsala",
(63, 58): "Stockholm",
(63, 57): "Stockholm",
(63, 56): "Stockholm",
(62, 56): "Stockholm",
(66, 59): "Helsinki",
(65, 59): "Helsinki",
(65, 58): "Helsinki",
(65, 58): "Vilnius",
(65, 55): "Vilnius",
(66, 54): "Vilnius",
(66, 55): "Vilnius",
(64, 53): "Vilnius",
(65, 53): "Vilnius",
(66, 53): "Vilnius",
(63, 50): "Vienna",
(64, 50): "Vienna",
(65, 50): "Vienna",
(65, 49): "Vienna",
(64, 49): "Vienna",
(63, 49): "Vienna",
(64, 52): "Warsaw",
(63, 51): "Warsaw",
(62, 48): "Venice",
(61, 48): "Venice",
(63, 48): "Venice",
(61, 43): "Palermo",
(62, 43): "Palermo",
(76, 32): "Sanaa",
(77, 32): "Sanaa",
(77, 33): "Sanaa",
(78, 33): "Sanaa",
(64, 12): "Cape Town",
(64, 13): "Cape Town",
(65, 13): "Cape Town",
(65, 12): "Cape Town",
(42, 18): "Rio De Janeiro",
(43, 19): "Rio De Janeiro",
(41, 18): "Rio De Janeiro",
(39, 15): "Montevideo",
(38, 14): "Montevideo",
(38, 13): "Montevideo",
(36, 13): "Buenos Aires",
(37, 13): "Buenos Aires",
(36, 12): "Buenos Aires",
(18, 39): "Mexico City",
(18, 38): "Mexico City",
(19, 39): "Mexico City",
(19, 40): "Mexico City",
(18, 49): "Mexico City",
(24, 45): "St. Louis",
(25, 45): "St. Louis",
(25, 46): "St. Louis",
(24, 46): "St. Louis",
(27, 38): "Havanna",
(28, 38): "Havanna",
(31, 37): "Port-au-Prince",
(31, 39): "Port-au-Prince",
(56, 50): "Nantes",
(59, 53): "Amsterdam",
(59, 52): "Amsterdam",
(28, 46): "Philadelphia",
(28, 45): "Philadelphia",
(27, 45): "Washington",
(27, 44): "Washington",
(96, 39): "Calcutta"
}




def nameNorm(pCity):
   coord = (pCity.getX(), pCity.getY())
   if coord in cityNameDict:
      name = cityNameDict[coord]
      pCity.setName(name)
      return True
   else:
      return False
 
Back
Top Bottom