ospace-devel Mailing List for Outer Space
Brought to you by:
qark
You can subscribe to this list here.
2007 |
Jan
(1) |
Feb
(2) |
Mar
(23) |
Apr
(21) |
May
(96) |
Jun
(81) |
Jul
(22) |
Aug
(29) |
Sep
|
Oct
(7) |
Nov
(30) |
Dec
(14) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(3) |
Feb
|
Mar
(5) |
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(4) |
Jun
(5) |
Jul
(8) |
Aug
(22) |
Sep
(7) |
Oct
(1) |
Nov
(1) |
Dec
(1) |
2011 |
Jan
(1) |
Feb
(3) |
Mar
(2) |
Apr
|
May
(2) |
Jun
(4) |
Jul
(1) |
Aug
(2) |
Sep
(1) |
Oct
(4) |
Nov
(8) |
Dec
(4) |
2012 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(4) |
Jul
(3) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <da...@us...> - 2013-02-02 17:45:16
|
Revision: 336 http://ospace.svn.sourceforge.net/ospace/?rev=336&view=rev Author: dahaic Date: 2013-02-02 17:45:09 +0000 (Sat, 02 Feb 2013) Log Message: ----------- Polish of tech parser code. [Lukc] Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/server/lib/ige/ospace/Rules/Techs.py Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2012-10-30 17:09:36 UTC (rev 335) +++ branches/ospace_0.5/ChangeLog.txt 2013-02-02 17:45:09 UTC (rev 336) @@ -6,6 +6,9 @@ - $Author$ - $Revision$ +[2013-02-02] +- Polishing of the code responsible for parsing of technologies [lukc] + [2012-10-30] - Fixed bug in Morale overlay evaluation. [dahaic] Modified: branches/ospace_0.5/server/lib/ige/ospace/Rules/Techs.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/Rules/Techs.py 2012-10-30 17:09:36 UTC (rev 335) +++ branches/ospace_0.5/server/lib/ige/ospace/Rules/Techs.py 2013-02-02 17:45:09 UTC (rev 336) @@ -256,54 +256,57 @@ self.tech = Technology(int(attrs['id']), attrs['symbol'], techs) setattr(Tech, attrs['symbol'], int(attrs['id'])) self.tech.set('name', attrs['name']) - elif self.state == 3 and name == 'structure': - self.tech.set('isStructure', 1) - for key in attrs.keys(): - self.tech.set(key, attrs[key]) - elif self.state == 3 and name == 'discovery': - self.tech.set('isDiscovery', 1) - for key in attrs.keys(): - self.tech.set(key, attrs[key]) - elif self.state == 3 and name == 'notdiscovery': - self.tech.set('isDiscovery', 0) - for key in attrs.keys(): - self.tech.set(key, attrs[key]) - elif self.state == 3 and name == 'starting': - self.tech.set('isStarting', 1) - for key in attrs.keys(): - self.tech.set(key, attrs[key]) - elif self.state == 3 and name == 'notstarting': - self.tech.set('isStarting', 0) - for key in attrs.keys(): - self.tech.set(key, attrs[key]) - elif self.state == 3 and name == 'shipequip': - self.tech.set('isShipEquip', 1) - for key in attrs.keys(): - self.tech.set(key, attrs[key]) - elif self.state == 3 and name == 'project': - self.tech.set('isProject', 1) - for key in attrs.keys(): - self.tech.set(key, attrs[key]) - elif self.state == 3 and name == 'shiphull': - self.tech.set('isShipHull', 1) - for key in attrs.keys(): - self.tech.set(key, attrs[key]) - elif self.state == 3 and name == 'mine': - self.tech.set('isMine', 1) - for key in attrs.keys(): - self.tech.set(key, attrs[key]) - elif self.state == 3 and name == 'data': - for key in attrs.keys(): - self.tech.set(key, attrs[key]) - elif self.state == 3 and name == 'preresearch': - self.state = 4 - self.text = '' - elif self.state == 3 and name == 'description': - self.state = 4 - self.text = '' - elif self.state == 3 and name == 'flavor': - self.state = 4 - self.text = '' + elif self.state == 3: + if name == 'structure': + self.tech.set('isStructure', 1) + for key in attrs.keys(): + self.tech.set(key, attrs[key]) + elif name == 'discovery': + self.tech.set('isDiscovery', 1) + for key in attrs.keys(): + self.tech.set(key, attrs[key]) + elif name == 'notdiscovery': + self.tech.set('isDiscovery', 0) + for key in attrs.keys(): + self.tech.set(key, attrs[key]) + elif name == 'starting': + self.tech.set('isStarting', 1) + for key in attrs.keys(): + self.tech.set(key, attrs[key]) + elif name == 'notstarting': + self.tech.set('isStarting', 0) + for key in attrs.keys(): + self.tech.set(key, attrs[key]) + elif name == 'shipequip': + self.tech.set('isShipEquip', 1) + for key in attrs.keys(): + self.tech.set(key, attrs[key]) + elif name == 'project': + self.tech.set('isProject', 1) + for key in attrs.keys(): + self.tech.set(key, attrs[key]) + elif name == 'shiphull': + self.tech.set('isShipHull', 1) + for key in attrs.keys(): + self.tech.set(key, attrs[key]) + elif name == 'mine': + self.tech.set('isMine', 1) + for key in attrs.keys(): + self.tech.set(key, attrs[key]) + elif name == 'data': + for key in attrs.keys(): + self.tech.set(key, attrs[key]) + elif name == 'preresearch': + self.state = 4 + self.text = '' + elif name == 'description': + self.state = 4 + self.text = '' + elif name == 'flavor': + self.state = 4 + self.text = '' + else: + raise 'Unsupported tag %s' % str(name) else: raise 'Unsupported tag %s' % str(name) @@ -313,15 +316,16 @@ elif self.state == 3 and name == 'technology': self.state = 2 #log.debug(repr(self.tech)) - elif self.state == 4 and name == 'preresearch': - self.tech.textPreRsrch = self.text - self.state = 3 - elif self.state == 4 and name == 'description': - self.tech.textDescr = self.text - self.state = 3 - elif self.state == 4 and name == 'flavor': - self.tech.textFlavor = self.text - self.state = 3 + elif self.state == 4: + if name == 'preresearch': + self.tech.textPreRsrch = self.text + self.state = 3 + elif name == 'description': + self.tech.textDescr = self.text + self.state = 3 + elif name == 'flavor': + self.tech.textFlavor = self.text + self.state = 3 def characters(self, text): self.text += text This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <da...@us...> - 2012-10-30 17:09:47
|
Revision: 335 http://ospace.svn.sourceforge.net/ospace/?rev=335&view=rev Author: dahaic Date: 2012-10-30 17:09:36 +0000 (Tue, 30 Oct 2012) Log Message: ----------- Fixed bug in Morale overlay. Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/client-pygame/lib/osci/StarMapWidget.py Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2012-07-20 20:17:23 UTC (rev 334) +++ branches/ospace_0.5/ChangeLog.txt 2012-10-30 17:09:36 UTC (rev 335) @@ -6,6 +6,9 @@ - $Author$ - $Revision$ +[2012-10-30] +- Fixed bug in Morale overlay evaluation. [dahaic] + [2012-07-20] - Pirate and EDEN now has forced non-aggresion, preventing Pirate from obtaining EDEN technologies. (fix for github issue #5) [dahaic] Modified: branches/ospace_0.5/client-pygame/lib/osci/StarMapWidget.py =================================================================== --- branches/ospace_0.5/client-pygame/lib/osci/StarMapWidget.py 2012-07-20 20:17:23 UTC (rev 334) +++ branches/ospace_0.5/client-pygame/lib/osci/StarMapWidget.py 2012-10-30 17:09:36 UTC (rev 335) @@ -1048,7 +1048,7 @@ centralPlanet = client.get(player.planets[0]) govPCR = player.govPwrCtrlRange player.stats.storPop, player.govPwr - for step in xrange(100, max(Rules.minMoraleTrgt-1, int(107.5-37.5*player.stats.storPop/player.govPwr) - 1) , -10): + for step in xrange(100, int(max(Rules.minMoraleTrgt-1, 107.5-37.5*player.stats.storPop/player.govPwr - 1)) , -10): moraleColor = res.getMoraleColors(step) centralX = int((centralPlanet.x - currX) * scale) + centerX centralY = maxY - (int((centralPlanet.y - currY) * scale) + centerY) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <da...@us...> - 2012-07-20 20:17:29
|
Revision: 334 http://ospace.svn.sourceforge.net/ospace/?rev=334&view=rev Author: dahaic Date: 2012-07-20 20:17:23 +0000 (Fri, 20 Jul 2012) Log Message: ----------- - Pirate and EDEN now has forced non-aggresion, preventing Pirate from obtaining EDEN technologies. (fix for github issue #5) Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/server/lib/ige/ospace/IAIEDENPlayer.py branches/ospace_0.5/server/lib/ige/ospace/IAIPiratePlayer.py branches/ospace_0.5/server/lib/ige/ospace/IPiratePlayer.py Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2012-07-20 08:57:59 UTC (rev 333) +++ branches/ospace_0.5/ChangeLog.txt 2012-07-20 20:17:23 UTC (rev 334) @@ -6,6 +6,10 @@ - $Author$ - $Revision$ +[2012-07-20] +- Pirate and EDEN now has forced non-aggresion, preventing Pirate from + obtaining EDEN technologies. (fix for github issue #5) [dahaic] + [2012-07-19] - NEW phase of buildings is now correctly respected in all cases. (fix for github issue #1) [dahaic] Modified: branches/ospace_0.5/server/lib/ige/ospace/IAIEDENPlayer.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/IAIEDENPlayer.py 2012-07-20 08:57:59 UTC (rev 333) +++ branches/ospace_0.5/server/lib/ige/ospace/IAIEDENPlayer.py 2012-07-20 20:17:23 UTC (rev 334) @@ -122,4 +122,9 @@ return dipl def isPactActive(self, tran, obj, partnerID, pactID): + partner = tran.db.get(partnerID, None) + if partner.type in (T_AIPIRPLAYER, T_PIRPLAYER): + # force the peace! + if pactID in (PACT_ALLOW_CIVILIAN_SHIPS, PACT_ALLOW_MILITARY_SHIPS): + return PACT_ACTIVE return 0 Modified: branches/ospace_0.5/server/lib/ige/ospace/IAIPiratePlayer.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/IAIPiratePlayer.py 2012-07-20 08:57:59 UTC (rev 333) +++ branches/ospace_0.5/server/lib/ige/ospace/IAIPiratePlayer.py 2012-07-20 20:17:23 UTC (rev 334) @@ -155,6 +155,11 @@ return dipl def isPactActive(self, tran, obj, partnerID, pactID): + partner = tran.db.get(partnerID, None) + if partner.type == T_AIEDENPLAYER: + # force the peace! + if pactID in (PACT_ALLOW_CIVILIAN_SHIPS, PACT_ALLOW_MILITARY_SHIPS): + return PACT_ACTIVE return 0 def processDIPLPhase(self, tran, obj, data): Modified: branches/ospace_0.5/server/lib/ige/ospace/IPiratePlayer.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/IPiratePlayer.py 2012-07-20 08:57:59 UTC (rev 333) +++ branches/ospace_0.5/server/lib/ige/ospace/IPiratePlayer.py 2012-07-20 20:17:23 UTC (rev 334) @@ -209,4 +209,12 @@ obj.diplomacyRels[party.oid] = diplSelf party.diplomacyRels[obj.oid] = diplEDEN - + + def isPactActive(self, tran, obj, partnerID, pactID): + partner = tran.db.get(partnerID, None) + if partner.type == T_AIEDENPLAYER: + # force the peace! + if pactID in (PACT_ALLOW_CIVILIAN_SHIPS, PACT_ALLOW_MILITARY_SHIPS): + return PACT_ACTIVE + # for other situations, handle it as proper player + return IPlayer.isPactActive(self, tran, obj, partnerID, pactID) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qa...@us...> - 2012-07-20 08:58:05
|
Revision: 333 http://ospace.svn.sourceforge.net/ospace/?rev=333&view=rev Author: qark Date: 2012-07-20 08:57:59 +0000 (Fri, 20 Jul 2012) Log Message: ----------- Buildings now remains switched on (fix for github issue #1) Modified Paths: -------------- branches/ospace_0.5/server/lib/ige/ospace/IPlanet.py Modified: branches/ospace_0.5/server/lib/ige/ospace/IPlanet.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/IPlanet.py 2012-07-19 21:14:40 UTC (rev 332) +++ branches/ospace_0.5/server/lib/ige/ospace/IPlanet.py 2012-07-20 08:57:59 UTC (rev 333) @@ -309,7 +309,7 @@ def processINITPhase(self, tran, obj, data): # get rid of the NEW states for struct in obj.slots: - struct[STRUCT_IDX_STATUS] &= ~STRUCT_STATUS_NEW + struct[STRUCT_IDX_STATUS] &= STRUCT_STATUS_RESETFLGS processINITPhase.public = 1 processINITPhase.accLevel = AL_ADMIN @@ -377,6 +377,7 @@ # reset of "morale modifier by buildings" value obj.moraleModifiers[1] = 0 for struct in obj.slots: + # skip structure if it was built this turn if struct[STRUCT_IDX_STATUS] & STRUCT_STATUS_NEW: continue tech = Rules.techs[struct[STRUCT_IDX_TECHID]] @@ -391,7 +392,6 @@ if obj.autoMinStor: obj.minBio += tech.operBio * Rules.autoMinStorTurns obj.minEn += tech.operEn * Rules.autoMinStorTurns - struct[STRUCT_IDX_STATUS] &= STRUCT_STATUS_RESETFLGS # each structure accomodate it's workers obj.maxPop += tech.operWorkers # produce/consume resources This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <da...@us...> - 2012-07-19 21:14:46
|
Revision: 332 http://ospace.svn.sourceforge.net/ospace/?rev=332&view=rev Author: dahaic Date: 2012-07-19 21:14:40 +0000 (Thu, 19 Jul 2012) Log Message: ----------- - NEW phase of buildings is now correctly respected in all cases. (fix for github issue #1) - Removed duplicate entries in the GalaxyNames.txt file. Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/server/data/GalaxyNames.txt branches/ospace_0.5/server/lib/ige/ospace/IPlanet.py branches/ospace_0.5/server/lib/ige/ospace/ISystem.py Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2012-06-11 20:24:23 UTC (rev 331) +++ branches/ospace_0.5/ChangeLog.txt 2012-07-19 21:14:40 UTC (rev 332) @@ -6,6 +6,11 @@ - $Author$ - $Revision$ +[2012-07-19] +- NEW phase of buildings is now correctly respected in all cases. + (fix for github issue #1) [dahaic] +- Removed duplicate entries in the GalaxyNames.txt file. [dahaic] + [2012-06-11] - GalaxyNames.txt file needed by Galaxer is now included. [dahaic] Modified: branches/ospace_0.5/server/data/GalaxyNames.txt =================================================================== --- branches/ospace_0.5/server/data/GalaxyNames.txt 2012-06-11 20:24:23 UTC (rev 331) +++ branches/ospace_0.5/server/data/GalaxyNames.txt 2012-07-19 21:14:40 UTC (rev 332) @@ -11,18 +11,3 @@ Kelenor Larion Merlis - -Argo -Beidos -Ceelia -Daela -Everen -Ferun -Garis -Hiron -Inera -Jinx -Kelenor -Larion -Merlis - Modified: branches/ospace_0.5/server/lib/ige/ospace/IPlanet.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/IPlanet.py 2012-06-11 20:24:23 UTC (rev 331) +++ branches/ospace_0.5/server/lib/ige/ospace/IPlanet.py 2012-07-19 21:14:40 UTC (rev 332) @@ -306,6 +306,15 @@ moveStruct.public = 1 moveStruct.accLevel = AL_FULL + def processINITPhase(self, tran, obj, data): + # get rid of the NEW states + for struct in obj.slots: + struct[STRUCT_IDX_STATUS] &= ~STRUCT_STATUS_NEW + + processINITPhase.public = 1 + processINITPhase.accLevel = AL_ADMIN + + def processPRODPhase(self, tran, obj, data): if obj.plType == "A": self.cmd(obj).generateAsteroid(tran, obj) @@ -368,6 +377,8 @@ # reset of "morale modifier by buildings" value obj.moraleModifiers[1] = 0 for struct in obj.slots: + if struct[STRUCT_IDX_STATUS] & STRUCT_STATUS_NEW: + continue tech = Rules.techs[struct[STRUCT_IDX_TECHID]] # compute struct effectivity techEff = Utils.getTechEff(tran, struct[STRUCT_IDX_TECHID], obj.owner) Modified: branches/ospace_0.5/server/lib/ige/ospace/ISystem.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/ISystem.py 2012-06-11 20:24:23 UTC (rev 331) +++ branches/ospace_0.5/server/lib/ige/ospace/ISystem.py 2012-07-19 21:14:40 UTC (rev 332) @@ -233,6 +233,8 @@ def processINITPhase(self, tran, obj, data): obj.scannerPwrs = {} + return obj.planets + processINITPhase.public = 1 processINITPhase.accLevel = AL_ADMIN This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <da...@us...> - 2012-06-11 20:24:29
|
Revision: 331 http://ospace.svn.sourceforge.net/ospace/?rev=331&view=rev Author: dahaic Date: 2012-06-11 20:24:23 +0000 (Mon, 11 Jun 2012) Log Message: ----------- - Added GalaxyNames.txt file needed by Galaxer. - Changed captions used during singleplayer galaxy selection for clarity. - Patched singleplayer branch with fix for scraping designs in global queue. Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/singleplayer/ChangeLog.txt branches/singleplayer/client-pygame/lib/osci/dialog/ConstructionDlg.py branches/singleplayer/client-pygame/lib/osci/dialog/GalaxerDlg.py branches/singleplayer/client-pygame/lib/pygameui/Entry.py branches/singleplayer/server/lib/ige/ospace/IPlayer.py Added Paths: ----------- branches/ospace_0.5/server/data/GalaxyNames.txt branches/singleplayer/client-pygame/lib/osci/dialog/SingleOptions.py branches/singleplayer/server/data/GalaxyNames.txt Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2012-06-09 10:07:10 UTC (rev 330) +++ branches/ospace_0.5/ChangeLog.txt 2012-06-11 20:24:23 UTC (rev 331) @@ -6,6 +6,9 @@ - $Author$ - $Revision$ +[2012-06-11] +- GalaxyNames.txt file needed by Galaxer is now included. [dahaic] + [2012-06-09] - TechViewer now counts effectivity of ship designs. [dahaic] - Twin EM Cannon Turret now costs less, to provide some incentive to research Added: branches/ospace_0.5/server/data/GalaxyNames.txt =================================================================== --- branches/ospace_0.5/server/data/GalaxyNames.txt (rev 0) +++ branches/ospace_0.5/server/data/GalaxyNames.txt 2012-06-11 20:24:23 UTC (rev 331) @@ -0,0 +1,28 @@ +Argo +Beidos +Ceelia +Daela +Everen +Ferun +Garis +Hiron +Inera +Jinx +Kelenor +Larion +Merlis + +Argo +Beidos +Ceelia +Daela +Everen +Ferun +Garis +Hiron +Inera +Jinx +Kelenor +Larion +Merlis + Modified: branches/singleplayer/ChangeLog.txt =================================================================== --- branches/singleplayer/ChangeLog.txt 2012-06-09 10:07:10 UTC (rev 330) +++ branches/singleplayer/ChangeLog.txt 2012-06-11 20:24:23 UTC (rev 331) @@ -6,6 +6,20 @@ - $Author$ - $Revision$ +[2012-06-11] +- Galaxer dialog for singleplayer mode has better captions. [dahaic] +- GalaxyNames and SingleOptionsDlg files are now included. [dahaic] + +[2012-06-09] +- TechViewer now counts effectivity of ship designs. [dahaic] +- Twin EM Cannon Turret now costs less, to provide some incentive to research + it. [dahaic] +- All NPC/devel techs has defined allowed races now. [dahaic] +- fixes for osclient and osclient.py [dahaic] +- Included list of galaxy names, used by Galaxer [dahaic] +- Scrapped designs are now correctly removed from global queues [dahaic] + + [2012-02-07] - Client now handles better situation when server is down. [Qark] - Server now supports metaserver accounts with local fallback. [Qark] Modified: branches/singleplayer/client-pygame/lib/osci/dialog/ConstructionDlg.py =================================================================== --- branches/singleplayer/client-pygame/lib/osci/dialog/ConstructionDlg.py 2012-06-09 10:07:10 UTC (rev 330) +++ branches/singleplayer/client-pygame/lib/osci/dialog/ConstructionDlg.py 2012-06-11 20:24:23 UTC (rev 331) @@ -367,7 +367,7 @@ self.win.setStatus(_("Executing SCRAP SHIP DESIGN command...")) player = client.getPlayer() oldFleets = player.fleets - player.shipDesigns, player.fleets, player.stratRes = \ + player.shipDesigns, player.fleets, player.stratRes, player.prodQueues = \ client.cmdProxy.scrapShipDesign(player.oid, self.selectedDesignID) self.selectedDesignID = None self.win.setStatus(_('Command has been executed.')) Modified: branches/singleplayer/client-pygame/lib/osci/dialog/GalaxerDlg.py =================================================================== --- branches/singleplayer/client-pygame/lib/osci/dialog/GalaxerDlg.py 2012-06-09 10:07:10 UTC (rev 330) +++ branches/singleplayer/client-pygame/lib/osci/dialog/GalaxerDlg.py 2012-06-11 20:24:23 UTC (rev 331) @@ -43,6 +43,10 @@ def show(self): items = [] + if client.single: + self.win.vToggleBooking.text = _('Start selected galaxy type') + else: + self.win.vToggleBooking.text = _('Toggle booking') for galaxyType in self.galaxerInfo: info, tPos, tCur, rawTime, isSelected = self.galaxerInfo[galaxyType] if rawTime: @@ -72,6 +76,8 @@ except IndexError: selectedType = None if selectedType: + if client.single: + self.win.setStatus(_('Galaxy is being generated.')) result = client.setPlayerPreference(selectedType) if not type(result) == type(True) and not result == True: self.galaxerInfo = result @@ -112,7 +118,7 @@ scrollBar = ui.Scrollbar(self.win, layout = (20, 6, 1, 4)) textBox = ui.Text(self.win, layout = (0, 6, 20, 4), id = "vInfo", editable = 0) textBox.attachVScrollbar(scrollBar) - ui.TitleButton(self.win, layout = (0, 10, 21, 1), text = _('Toggle booking'), action = 'onToggle') + ui.TitleButton(self.win, layout = (0, 10, 21, 1), id = 'vToggleBooking', text = '', action = 'onToggle') ui.Title(self.win, layout = (0, 11, 17, 1), id = 'vStatusBar', align = ui.ALIGN_W) ui.TitleButton(self.win, layout = (17, 11, 4, 1), text = _('Exit'), action = 'onCancel') self.win.statusBar = self.win.vStatusBar Added: branches/singleplayer/client-pygame/lib/osci/dialog/SingleOptions.py =================================================================== --- branches/singleplayer/client-pygame/lib/osci/dialog/SingleOptions.py (rev 0) +++ branches/singleplayer/client-pygame/lib/osci/dialog/SingleOptions.py 2012-06-11 20:24:23 UTC (rev 331) @@ -0,0 +1,66 @@ +# +# Copyright 2001 - 2011 Ludek Smid [http://www.ospace.net/] +# +# This file is part of Outer Space. +# +# Outer Space is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# Outer Space is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Outer Space; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +import time + +import pygameui as ui +from osci import client, gdata, res +from ige.ospace.Const import * +import ige + +class SingleOptionsDlg: + """ All options relevant to singleplayer.""" + + def __init__(self, app): + self.app = app + self.createUI() + + def display(self, caller = None): + self.caller = caller + if self.show(): + self.win.show() + + def hide(self): + self.win.hide() + + def show(self): + items = [] + return True + + def onCancel(self, widget, action, data): + self.win.hide() + if self.caller: + self.caller.display() + else: + self.win.hide() + + def createUI(self): + w, h = gdata.scrnSize + self.win = ui.Window(self.app, + modal = 1, + movable = 0, + title = _('Singleplayer options'), + rect = ui.Rect((w - 424) / 2, (h - 264) / 2, 424, 264), + layoutManager = ui.SimpleGridLM(), + tabChange = True + ) + self.win.subscribeAction('*', self) + ui.Title(self.win, layout = (0, 11, 17, 1), id = 'vStatusBar', align = ui.ALIGN_W) + ui.TitleButton(self.win, layout = (17, 11, 4, 1), text = _('Close'), action = 'onCancel') + self.win.statusBar = self.win.vStatusBar Modified: branches/singleplayer/client-pygame/lib/pygameui/Entry.py =================================================================== --- branches/singleplayer/client-pygame/lib/pygameui/Entry.py 2012-06-09 10:07:10 UTC (rev 330) +++ branches/singleplayer/client-pygame/lib/pygameui/Entry.py 2012-06-11 20:24:23 UTC (rev 331) @@ -100,7 +100,7 @@ self.cursorPos = len(self.text) def onFocusLost(self): -# Widget.onFocusLost(self) + Widget.onFocusLost(self) self.processAction(self.action) registerWidget(Entry, 'entry') Added: branches/singleplayer/server/data/GalaxyNames.txt =================================================================== --- branches/singleplayer/server/data/GalaxyNames.txt (rev 0) +++ branches/singleplayer/server/data/GalaxyNames.txt 2012-06-11 20:24:23 UTC (rev 331) @@ -0,0 +1,14 @@ +Argo +Beidos +Ceelia +Daela +Everen +Ferun +Garis +Hiron +Inera +Jinx +Kelenor +Larion +Merlis + Modified: branches/singleplayer/server/lib/ige/ospace/IPlayer.py =================================================================== --- branches/singleplayer/server/lib/ige/ospace/IPlayer.py 2012-06-09 10:07:10 UTC (rev 330) +++ branches/singleplayer/server/lib/ige/ospace/IPlayer.py 2012-06-11 20:24:23 UTC (rev 331) @@ -513,6 +513,11 @@ for planetID in obj.planets: planet = tran.db[planetID] self.cmd(planet).deleteDesign(tran, planet, designID) + # delete from global queues + for queueID in xrange(len(obj.prodQueues)): + for taskID in xrange(len(obj.prodQueues[queueID])): + if obj.prodQueues[queueID][taskID].techID == designID: + self.cmd(obj).abortGlobalConstruction(tran, obj, queueID, taskID) # clear upgradeTo for tmpDesignID in obj.shipDesigns: spec = obj.shipDesigns[tmpDesignID] @@ -520,7 +525,7 @@ spec.upgradeTo = 0 # delete design del obj.shipDesigns[designID] - return obj.shipDesigns, obj.fleets, obj.stratRes + return obj.shipDesigns, obj.fleets, obj.stratRes, obj.prodQueues scrapShipDesign.public = 1 scrapShipDesign.accLevel = AL_OWNER This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <da...@us...> - 2012-06-09 10:07:17
|
Revision: 330 http://ospace.svn.sourceforge.net/ospace/?rev=330&view=rev Author: dahaic Date: 2012-06-09 10:07:10 +0000 (Sat, 09 Jun 2012) Log Message: ----------- - TechViewer now counts effectivity of ship designs. [dahaic] - Twin EM Cannon Turret now costs less, to provide some incentive to research it. [dahaic] - All NPC/devel techs has defined allowed races now. [dahaic] - fixes for osclient and osclient.py [dahaic] - Included list of galaxy names, used by Galaxer [dahaic] - Scrapped designs are now correctly removed from global queues [dahaic] Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/client-TechViewer/ConstructionDlg.py branches/ospace_0.5/client-TechViewer/TechViewer.py branches/ospace_0.5/client-pygame/lib/osci/dialog/ConstructionDlg.py branches/ospace_0.5/server/lib/ige/ospace/IPlayer.py branches/ospace_0.5/server/lib/ige/ospace/Rules/QDev-Bonus.xml branches/ospace_0.5/server/lib/ige/ospace/Rules/Setup.xml branches/ospace_0.5/server/lib/ige/ospace/Rules/TL2.xml branches/ospace_0.5/server/osclient branches/ospace_0.5/server/osclient.py Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2012-06-09 08:27:28 UTC (rev 329) +++ branches/ospace_0.5/ChangeLog.txt 2012-06-09 10:07:10 UTC (rev 330) @@ -6,6 +6,15 @@ - $Author$ - $Revision$ +[2012-06-09] +- TechViewer now counts effectivity of ship designs. [dahaic] +- Twin EM Cannon Turret now costs less, to provide some incentive to research + it. [dahaic] +- All NPC/devel techs has defined allowed races now. [dahaic] +- fixes for osclient and osclient.py [dahaic] +- Included list of galaxy names, used by Galaxer [dahaic] +- Scrapped designs are now correctly removed from global queues [dahaic] + [2012-02-07] - Client now handles better situation when server is down. [Qark] - Server now supports metaserver accounts with local fallback. [Qark] Modified: branches/ospace_0.5/client-TechViewer/ConstructionDlg.py =================================================================== --- branches/ospace_0.5/client-TechViewer/ConstructionDlg.py 2012-06-09 08:27:28 UTC (rev 329) +++ branches/ospace_0.5/client-TechViewer/ConstructionDlg.py 2012-06-09 10:07:10 UTC (rev 330) @@ -1,5 +1,6 @@ import wx import string +import math import sequip @@ -247,6 +248,16 @@ box.Add(self.lblConstrPts, 1, wx.GROW | wx.ALIGN_RIGHT, 0) right.AddSizer(box, 0, wx.GROW, 0) + right.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 4) + + box = wx.BoxSizer(wx.HORIZONTAL) + label = wx.StaticText(self, -1, "Effectivity") + self.lblEffPts = wx.StaticText(self, -1, "", style = wx.ALIGN_RIGHT) + box.Add(label, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 4) + box.Add(self.lblEffPts, 1, wx.GROW | wx.ALIGN_RIGHT, 0) + right.AddSizer(box, 0, wx.GROW, 0) + + box = wx.BoxSizer(wx.VERTICAL) constrBtnID = wx.NewId() self.constrBtn = wx.Button(self, constrBtnID, "Construct") @@ -457,6 +468,18 @@ self.lblBaseExp.SetLabel("%d" % self.selectedDesign.baseExp) self.lblMP.SetLabel("%d" % self.selectedDesign.combatPwr) self.designName.SetLabel(self.selectedDesign.name) + # effectivity + speedEff = 1/(1+math.exp((6 -self.selectedDesign.speed) * 2 - 2)) + dmg = 0 + for weaponID in self.selectedDesign.weaponIDs: + weapon = Rules.techs[weaponID] + dmg += (weapon.weaponDmgMin + weapon.weaponDmgMax) / 2 * weapon.weaponROF * (0.75 + 4 * 0.125) + if self.selectedDesign.buildProd: + dmgEff = max(1, dmg) / self.selectedDesign.buildProd + hpEff = float(self.selectedDesign.maxHP + self.selectedDesign.shieldHP) / self.selectedDesign.buildProd + else: + dmgEff = hpEff = 0 + self.lblEffPts.SetLabel("%f" % (speedEff * dmgEff * hpEff)) i = 0 self.equipment.Freeze() self.equipment.DeleteAllItems() Modified: branches/ospace_0.5/client-TechViewer/TechViewer.py =================================================================== --- branches/ospace_0.5/client-TechViewer/TechViewer.py 2012-06-09 08:27:28 UTC (rev 329) +++ branches/ospace_0.5/client-TechViewer/TechViewer.py 2012-06-09 10:07:10 UTC (rev 330) @@ -1,3 +1,4 @@ +#!/usr/bin/python import wx import sys import os Modified: branches/ospace_0.5/client-pygame/lib/osci/dialog/ConstructionDlg.py =================================================================== --- branches/ospace_0.5/client-pygame/lib/osci/dialog/ConstructionDlg.py 2012-06-09 08:27:28 UTC (rev 329) +++ branches/ospace_0.5/client-pygame/lib/osci/dialog/ConstructionDlg.py 2012-06-09 10:07:10 UTC (rev 330) @@ -367,7 +367,7 @@ self.win.setStatus(_("Executing SCRAP SHIP DESIGN command...")) player = client.getPlayer() oldFleets = player.fleets - player.shipDesigns, player.fleets, player.stratRes = \ + player.shipDesigns, player.fleets, player.stratRes, player.prodQueues = \ client.cmdProxy.scrapShipDesign(player.oid, self.selectedDesignID) self.selectedDesignID = None self.win.setStatus(_('Command has been executed.')) Modified: branches/ospace_0.5/server/lib/ige/ospace/IPlayer.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/IPlayer.py 2012-06-09 08:27:28 UTC (rev 329) +++ branches/ospace_0.5/server/lib/ige/ospace/IPlayer.py 2012-06-09 10:07:10 UTC (rev 330) @@ -513,6 +513,11 @@ for planetID in obj.planets: planet = tran.db[planetID] self.cmd(planet).deleteDesign(tran, planet, designID) + # delete from global queues + for queueID in xrange(len(obj.prodQueues)): + for taskID in xrange(len(queue)): + if obj.prodQueues[queueID][taskID].techID == designID: + self.cmd(obj).abortGlobalConstruction(queueID, taskID) # clear upgradeTo for tmpDesignID in obj.shipDesigns: spec = obj.shipDesigns[tmpDesignID] Modified: branches/ospace_0.5/server/lib/ige/ospace/Rules/QDev-Bonus.xml =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/Rules/QDev-Bonus.xml 2012-06-09 08:27:28 UTC (rev 329) +++ branches/ospace_0.5/server/lib/ige/ospace/Rules/QDev-Bonus.xml 2012-06-09 10:07:10 UTC (rev 330) @@ -25,6 +25,7 @@ <discovery researchMod="1" level="1" + researchRaces="#" researchReqSRes="SR_TLAA" /> <project @@ -39,6 +40,7 @@ <discovery researchMod="1" level="1" + researchRaces="#" researchReqSRes="SR_TLAA" /> <project @@ -53,6 +55,7 @@ <discovery researchMod="1" level="1" + researchRaces="#" researchReqSRes="SR_TLAA" /> <project @@ -67,6 +70,7 @@ <discovery researchMod="1" level="1" + researchRaces="#" researchReqSRes="SR_TLAA" /> <project Modified: branches/ospace_0.5/server/lib/ige/ospace/Rules/Setup.xml =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/Rules/Setup.xml 2012-06-09 08:27:28 UTC (rev 329) +++ branches/ospace_0.5/server/lib/ige/ospace/Rules/Setup.xml 2012-06-09 10:07:10 UTC (rev 330) @@ -24,6 +24,7 @@ <technology id="9000" symbol="RENEGADEBASE" name="Renegade Outpost"> <discovery researchMod="1.0 + 0.5" + researchRaces="r" level="99" /> <structure @@ -49,6 +50,7 @@ <technology id="9060" symbol="RENEGADEBASE2" name="Renegade Base"> <discovery researchMod="1.0 + 0.5" + researchRaces="r" level="99" /> <structure @@ -74,6 +76,7 @@ <technology id="9061" symbol="RENEGADEBASE2MINOR" name="Renegade Camp"> <discovery researchMod="1.0 + 0.5" + researchRaces="r" level="99" /> <structure @@ -96,6 +99,7 @@ <technology id="9062" symbol="RENEGADEBASE3" name="Renegade HQ"> <discovery researchMod="1.0 + 0.5" + researchRaces="r" level="99" /> <structure @@ -122,6 +126,7 @@ <technology id="9063" symbol="RENEGADEBASE3MINOR" name="Renegade Fort"> <discovery researchMod="1.0 + 0.5" + researchRaces="r" level="99" /> <structure @@ -144,6 +149,7 @@ <technology id="9064" symbol="RENEGADECOSMODROME" name="Renegade Cosmodrome"> <discovery researchMod="1.0 + 0.5" + researchRaces="r" level="99" /> <structure @@ -164,6 +170,7 @@ <technology id="9001" symbol="MUTANTBASE" name="Mutant Lodge"> <discovery researchMod="1.0 + 0.5" + researchRaces="m" level="99" /> <structure @@ -192,6 +199,7 @@ <technology id="9070" symbol="MUTANTBASE2" name="Mutant Den"> <discovery researchMod="1.0 + 0.5" + researchRaces="m" level="99" /> <structure @@ -216,6 +224,7 @@ <technology id="9071" symbol="MUTANTBASE3" name="Mutant Hub"> <discovery researchMod="1.0 + 0.5" + researchRaces="m" level="99" /> <structure @@ -240,6 +249,7 @@ <technology id="9072" symbol="MUTANTPP1" name="Geothermal Power Plant"> <discovery researchMod="1.0 + 0.5" + researchRaces="m" level="99" /> <structure @@ -254,6 +264,7 @@ <technology id="9073" symbol="MUTANTPP2" name="Lightning Power Plant"> <discovery researchMod="1.0 + 0.5" + researchRaces="m" level="99" /> <structure @@ -268,6 +279,7 @@ <technology id="9074" symbol="MUTANTFACT1" name="Mutant Factory"> <discovery researchMod="1.0 + 0.5" + researchRaces="m" level="99" /> <structure @@ -283,6 +295,7 @@ <technology id="9075" symbol="MUTANTFACT2" name="Mutant Military Factory"> <discovery researchMod="1.0 + 0.5" + researchRaces="m" level="99" /> <structure @@ -304,6 +317,7 @@ <technology id="9076" symbol="MUTANTMINES" name="Mutant Mine Field"> <discovery researchMod="1.0 + 0.5" + researchRaces="m" level="99" /> <structure @@ -323,6 +337,7 @@ <technology id="9077" symbol="MUTANTBASE4" name="Mutant Junction"> <discovery researchMod="1.0 + 0.5" + researchRaces="m" level="99" /> <structure @@ -347,8 +362,8 @@ <technology id="9079" symbol="MUTANTPOD" name="Mutant planetary pod"> <discovery researchMod="1.00 + 0.50" + researchRaces="m" level="99" - researchRaces="m" /> <shipequip subtype="seq_struct" @@ -366,6 +381,7 @@ <technology id="9003" symbol="EDENBASE" name="E.D.E.N. Base"> <discovery researchMod="1.0 + 0.5" + researchRaces="e" level="99" /> <structure @@ -419,6 +435,7 @@ <technology id="9002" symbol="PIRATEBASE" name="Pirate Base"> <discovery researchMod="1.0 + 0.5" + researchRaces="p" level="99" /> <structure @@ -450,6 +467,7 @@ <technology id="9006" symbol="PIRATEDEN" name="Pirate Den"> <discovery researchMod="1.0 + 0.5" + researchRaces="p" level="99" /> <structure @@ -469,6 +487,7 @@ <technology id="9007" symbol="PIRATESD" name="Pirate Shipyards"> <discovery researchMod="1.00" + researchRaces="p" level="99" /> <structure @@ -491,6 +510,7 @@ <technology id="9008" symbol="PIRATEFTLENG" name="Pirate FTL Engine"> <discovery researchMod="1.00 + 1.00" + researchRaces="p" level="99" /> <shipequip @@ -507,6 +527,7 @@ <technology id="9009" symbol="PIRCOLONYMOD" name="Pirate Colony Module"> <discovery researchMod="1.00 + 0.50" + researchRaces="p" level="99" /> <shipequip @@ -526,6 +547,7 @@ <technology id="9010" symbol="PIRGOVERNMENT" name="Main Pirate Base"> <discovery researchMod="1.50" + researchRaces="p" level="99" /> <structure @@ -545,7 +567,7 @@ <discovery researchMod="1.00" level="99" - researchRaces="B" + researchRaces="C" maxImprovement="1" /> <structure @@ -577,7 +599,7 @@ <discovery researchMod="1.00" level="99" - researchRaces="B" + researchRaces="B" maxImprovement="1" /> <structure @@ -610,7 +632,7 @@ <discovery researchMod="1.00" level="99" - researchRaces="B" + researchRaces="B" maxImprovement="1" /> <structure @@ -637,6 +659,7 @@ <technology id="9020" symbol="EDENSTATION" name="Empire DEfense Network (E.D.E.N.) Flak Platform"> <discovery researchMod="1.0 + 0.5" + researchRaces="e" level="99" /> <structure @@ -659,6 +682,7 @@ <technology id="9021" symbol="EDENCANNON" name="E.D.E.N. Spacial Disruptor"> <discovery researchMod="1.00 + 0.5 + 0.5" + researchRaces="e" level="99" /> <shipequip @@ -679,6 +703,7 @@ <technology id="9022" symbol="EDENMISSILE" name="E.D.E.N. Hunter-Seeker"> <discovery researchMod="1.00 + 0.5 + 0.5" + researchRaces="e" level="99" /> <shipequip @@ -700,6 +725,7 @@ <technology id="9023" symbol="EDENTORP" name="E.D.E.N. Atomizer"> <discovery researchMod="1.00 + 0.5 + 0.5" + researchRaces="e" level="99" /> <shipequip @@ -721,6 +747,7 @@ <technology id="9024" symbol="EDENBOMB" name="E.D.E.N. Singularity Bomb"> <discovery researchMod="1.00 + 0.5 + 0.5" + researchRaces="e" level="99" /> <shipequip @@ -741,6 +768,7 @@ <technology id="9030" symbol="PIRATEBREWERY" name="Pirate Brewery"> <discovery researchMod="1.0 + 0.5" + researchRaces="p" level="99" /> <structure @@ -760,6 +788,7 @@ <technology id="9031" symbol="PIRATEPRISON" name="Pirate Prison"> <discovery researchMod="1.0 + 0.5" + researchRaces="p" level="99" /> <structure @@ -777,6 +806,7 @@ <technology id="9032" symbol="PIRATESMALLBASE" name="Pirate Small Base"> <discovery researchMod="1.0 + 0.5" + researchRaces="p" level="99" /> <structure @@ -808,6 +838,7 @@ <technology id="9033" symbol="PIRSMCOLONYMOD" name="Pirate Small Colony Module"> <discovery researchMod="1.00 + 0.50" + researchRaces="p" level="99" /> <shipequip @@ -889,6 +920,7 @@ <technology id="99001" symbol="COMSCANDEVEL" name="Developer Testing Comm/Scan Center"> <discovery researchMod="1.0" + researchRaces="#" level="99" /> <structure @@ -906,6 +938,7 @@ <technology id="99002" symbol="FACTORYDEVEL" name="Developer Testing Factory"> <discovery researchMod="1.0" + researchRaces="#" level="99" /> <structure @@ -927,6 +960,7 @@ <technology id="99003" symbol="FTLDEVEL" name="Developer FTL"> <discovery researchMod="1.0" + researchRaces="#" level="99" /> <shipequip @@ -944,6 +978,7 @@ <technology id="99004" symbol="SCANNERDEVEL" name="Developer Scanner"> <discovery researchMod="1.0" + researchRaces="#" level="99" /> <shipequip Modified: branches/ospace_0.5/server/lib/ige/ospace/Rules/TL2.xml =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/Rules/TL2.xml 2012-06-09 08:27:28 UTC (rev 329) +++ branches/ospace_0.5/server/lib/ige/ospace/Rules/TL2.xml 2012-06-09 10:07:10 UTC (rev 330) @@ -384,7 +384,7 @@ subtype="seq_wpn" slots="2" weight="4" - buildProd="608" + buildProd="456" weaponDmgMin="3" weaponDmgMax="5" weaponAtt="11" @@ -393,7 +393,7 @@ weaponIgnoreShield="0" minHull="1" /> - <preresearch>This flak cannon can be mounted on medium to large ships to help deffend them against fighters.</preresearch> + <preresearch>This flak cannon can be mounted on medium to large ships to help defend them against fighters.</preresearch> </technology> <technology id="2801" symbol="NFURANIUM" name="Nuclear Fusion - Uranium"> <discovery Modified: branches/ospace_0.5/server/osclient =================================================================== --- branches/ospace_0.5/server/osclient 2012-06-09 08:27:28 UTC (rev 329) +++ branches/ospace_0.5/server/osclient 2012-06-09 10:07:10 UTC (rev 330) @@ -20,14 +20,20 @@ # # tweak PYTHONPATH +import os import sys -sys.path.insert(0, 'lib') +# setup system path +baseDir = os.path.abspath(os.path.dirname(__file__)) + +sys.path.insert(0, os.path.join(baseDir, "lib")) + import os from igeclient.IClient import IClient import pprint, traceback from getpass import getpass from optparse import OptionParser +import ige from ige import log def msgHandler(id, data): @@ -55,8 +61,12 @@ help = "Backup server databases into BASEFILENAME-<database name>.osbackup") parser.add_option("", "--configdir", dest = "configDir", metavar = "DIRECTORY", default = "var", - help = "Override default configuration directory", -) + help = "Override default configuration directory",) +parser.add_option("", "--game", dest = "game", + metavar = "GAME", default = "Alpha", + help = "Name of the game") + + options, args = parser.parse_args() #s = IClient('ospace.net:9080', None, msgHandler, 'IClient/osc') @@ -74,7 +84,7 @@ password = getpass("Password: ") s.connect(login) -s.login('Alpha', login, password) +s.login(options.game, login, password) if options.backup: s.backup(options.backup) Modified: branches/ospace_0.5/server/osclient.py =================================================================== --- branches/ospace_0.5/server/osclient.py 2012-06-09 08:27:28 UTC (rev 329) +++ branches/ospace_0.5/server/osclient.py 2012-06-09 10:07:10 UTC (rev 330) @@ -503,7 +503,7 @@ print "Usage: osclient [options] LOGIN" sys.exit(1) -login = sys.argv[1] +login = args[0] if login == "admin": # get admin login from <configDir>/token This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <da...@us...> - 2012-06-09 08:27:37
|
Revision: 329 http://ospace.svn.sourceforge.net/ospace/?rev=329&view=rev Author: dahaic Date: 2012-06-09 08:27:28 +0000 (Sat, 09 Jun 2012) Log Message: ----------- Initial commit of singleplayer code. Modified Paths: -------------- branches/singleplayer/client-TechViewer/ConstructionDlg.py branches/singleplayer/client-TechViewer/TechViewer.py branches/singleplayer/client-ai/ai_main.py branches/singleplayer/client-ai/ai_osc.py branches/singleplayer/client-ai/ai_parser.py branches/singleplayer/client-pygame/lib/osci/StarMapWidget.py branches/singleplayer/client-pygame/lib/osci/client.py branches/singleplayer/client-pygame/lib/osci/dialog/GalaxerDlg.py branches/singleplayer/client-pygame/lib/osci/dialog/LoginDlg.py branches/singleplayer/client-pygame/lib/osci/dialog/MainGameDlg.py branches/singleplayer/client-pygame/lib/osci/dialog/NewAccountDlg.py branches/singleplayer/client-pygame/lib/osci/main.py branches/singleplayer/client-pygame/lib/osci/messages.py branches/singleplayer/client-pygame/lib/pygameui/Application.py branches/singleplayer/client-pygame/lib/pygameui/Entry.py branches/singleplayer/client-pygame/osc.py branches/singleplayer/server/lib/ige/ClientMngr.py branches/singleplayer/server/lib/ige/Const.py branches/singleplayer/server/lib/ige/GameMngr.py branches/singleplayer/server/lib/ige/RPCServer.py branches/singleplayer/server/lib/ige/__init__.py branches/singleplayer/server/lib/ige/ospace/Const.py branches/singleplayer/server/lib/ige/ospace/GameMngr.py branches/singleplayer/server/lib/ige/ospace/IAIEDENPlayer.py branches/singleplayer/server/lib/ige/ospace/IAIMutantPlayer.py branches/singleplayer/server/lib/ige/ospace/IAIPiratePlayer.py branches/singleplayer/server/lib/ige/ospace/IAIPlayer.py branches/singleplayer/server/lib/ige/ospace/IAIRenegadePlayer.py branches/singleplayer/server/lib/ige/ospace/IGalaxy.py branches/singleplayer/server/lib/ige/ospace/IPlayer.py branches/singleplayer/server/lib/ige/ospace/IUniverse.py branches/singleplayer/server/lib/ige/ospace/Rules/QDev-Bonus.xml branches/singleplayer/server/lib/ige/ospace/Rules/Setup.xml branches/singleplayer/server/lib/ige/ospace/Rules/TL2.xml branches/singleplayer/server/lib/igeclient/IClient.py branches/singleplayer/server/osclient branches/singleplayer/server/osclient.py branches/singleplayer/server/run.py branches/singleplayer/server/run_ai.py branches/singleplayer/server/run_galaxer.py Modified: branches/singleplayer/client-TechViewer/ConstructionDlg.py =================================================================== --- branches/singleplayer/client-TechViewer/ConstructionDlg.py 2012-06-09 06:21:25 UTC (rev 328) +++ branches/singleplayer/client-TechViewer/ConstructionDlg.py 2012-06-09 08:27:28 UTC (rev 329) @@ -1,5 +1,6 @@ import wx import string +import math import sequip @@ -247,6 +248,16 @@ box.Add(self.lblConstrPts, 1, wx.GROW | wx.ALIGN_RIGHT, 0) right.AddSizer(box, 0, wx.GROW, 0) + right.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 4) + + box = wx.BoxSizer(wx.HORIZONTAL) + label = wx.StaticText(self, -1, "Effectivity") + self.lblEffPts = wx.StaticText(self, -1, "", style = wx.ALIGN_RIGHT) + box.Add(label, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 4) + box.Add(self.lblEffPts, 1, wx.GROW | wx.ALIGN_RIGHT, 0) + right.AddSizer(box, 0, wx.GROW, 0) + + box = wx.BoxSizer(wx.VERTICAL) constrBtnID = wx.NewId() self.constrBtn = wx.Button(self, constrBtnID, "Construct") @@ -457,6 +468,18 @@ self.lblBaseExp.SetLabel("%d" % self.selectedDesign.baseExp) self.lblMP.SetLabel("%d" % self.selectedDesign.combatPwr) self.designName.SetLabel(self.selectedDesign.name) + # effectivity + speedEff = 1/(1+math.exp((6 -self.selectedDesign.speed) * 2 - 2)) + dmg = 0 + for weaponID in self.selectedDesign.weaponIDs: + weapon = Rules.techs[weaponID] + dmg += (weapon.weaponDmgMin + weapon.weaponDmgMax) / 2 * weapon.weaponROF * (0.75 + 4 * 0.125) + if self.selectedDesign.buildProd: + dmgEff = max(1, dmg) / self.selectedDesign.buildProd + hpEff = float(self.selectedDesign.maxHP + self.selectedDesign.shieldHP) / self.selectedDesign.buildProd + else: + dmgEff = hpEff = 0 + self.lblEffPts.SetLabel("%f" % (speedEff * dmgEff * hpEff)) i = 0 self.equipment.Freeze() self.equipment.DeleteAllItems() Modified: branches/singleplayer/client-TechViewer/TechViewer.py =================================================================== --- branches/singleplayer/client-TechViewer/TechViewer.py 2012-06-09 06:21:25 UTC (rev 328) +++ branches/singleplayer/client-TechViewer/TechViewer.py 2012-06-09 08:27:28 UTC (rev 329) @@ -1,3 +1,4 @@ +#!/usr/bin/python import wx import sys import os Modified: branches/singleplayer/client-ai/ai_main.py =================================================================== --- branches/singleplayer/client-ai/ai_main.py 2012-06-09 06:21:25 UTC (rev 328) +++ branches/singleplayer/client-ai/ai_main.py 2012-06-09 08:27:28 UTC (rev 329) @@ -18,95 +18,136 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -import time +import os +import optparse +import sys -from config import Config +class OptionsAIClient(optparse.Values): + def __init__(self): + self.configDir = os.path.join(os.path.expanduser("~"), ".outerspace") + self.server = "www.ospace.net:9080" + self.login = None + self.password = None + self.ai = None + self.game = "Alpha" -import osci, random, time -import ige.version -from ige import log -import sys, os, os.path -import re -from optparse import OptionParser +def runAIClient(options, args): + import time + import sys + import os -# log initialization -log.message("Starting Outer Space Client", ige.version.versionStringFull) -log.debug("sys.path =", sys.path) -log.debug("os.name =", os.name) -log.debug("sys.platform =", sys.platform) -log.debug("os.getcwd() =", os.getcwd()) -log.debug("sys.frozen =", getattr(sys, "frozen", None)) + # tweak PYTHONPATH + basepath = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -# parse command line parameters -parser = OptionParser() -parser.add_option("", "--configdir", dest = "configDir", - metavar = "DIRECTORY", - default = os.path.join(os.path.expanduser("~"), ".outerspace"), - help = "Override default configuration directory", -) -parser.add_option("", "--server", dest = "server", - metavar = "HOSTNAME:PORT", - default = "www.ospace.net:9080", - help = "Outer Space server location" -) -parser.add_option("", "--login", dest = "login", - metavar = "LOGIN", - default = None, - help = "Login name of the AI player.", -) -parser.add_option("", "--password", dest = "password", - metavar = "PASSWORD", - default = None, - help = "Corresponding password of the AI player.", -) -parser.add_option("", "--ai", dest = "ai", - metavar = "AI", - default = None, - help = "Type of the AI applied." -) + sys.path.insert(0, os.path.join(basepath, "client-pygame/lib")) + sys.path.insert(0, os.path.join(basepath, "client-pygame/lib/osci")) -options, args = parser.parse_args() + for item in ("libsrvr", "server/lib"): + path = os.path.join(basepath, item) + if os.path.exists(path): + sys.path.insert(0, path) + break -if args: - parser.error("No additional arguments are supported") + from config import Config -# create required directories -if not os.path.exists(options.configDir): - os.makedirs(options.configDir) + import osci, random, time + import ige.version + from ige import log + import os, os.path + import re -# client -import ai_client as client -import ai_handler -from igeclient.IClient import IClientException -if options.ai: - exec ("import AIs." + options.ai + " as ai") -else: - raise Exception -from ige.ospace.Const import * + # log initialization + log.message("Starting Outer Space Client", ige.version.versionStringFull) + log.debug("sys.path =", sys.path) + log.debug("os.name =", os.name) + log.debug("sys.platform =", sys.platform) + log.debug("os.getcwd() =", os.getcwd()) + log.debug("sys.frozen =", getattr(sys, "frozen", None)) -import gdata -gdata.config = Config(os.path.join(options.configDir, 'ais_dummy')) -client.initialize(options.server, ai_handler, options) + # create required directories + if not os.path.exists(options.configDir): + os.makedirs(options.configDir) -import gettext -tran = gettext.NullTranslations() -tran.install(unicode = 1) + # client + import ai_client as client + import ai_handler + from igeclient.IClient import IClientException + if options.ai: + ai = __import__("AIs." + options.ai) + ai = sys.modules["AIs." + options.ai] + else: + raise Exception -if options.login: - login = options.login -else: - raise Exception, 'You have to provide login.' + import ige.ospace.Const as Const -if options.password: - password = options.password -else: - raise Exception, 'You have to provide password.' + import gdata + # reload is here for multiprocessing support (as the process is used more + # than once + reload(client) + gdata.config = Config(os.path.join(options.configDir, 'ais_dummy')) + client.initialize(options.server, ai_handler, options) -client.login('Alpha', login, password) -# event loop -client.updateDatabase() -ai.run(client) + import gettext + tran = gettext.NullTranslations() + tran.install(unicode = 1) -client.logout() + if options.login: + login = options.login + else: + raise Exception, 'You have to provide login.' -log.debug("Shut down") + if options.password: + password = options.password + else: + raise Exception, 'You have to provide password.' + + client.login(options.game, login, password) + # event loop + client.updateDatabase() + ai.run(client) + + client.logout() + + log.debug("Shut down") + +if __name__ == '__main__': + + # parse command line parameters + parser = OptionParser() + parser.add_option("", "--configdir", dest = "configDir", + metavar = "DIRECTORY", + default = os.path.join(os.path.expanduser("~"), ".outerspace"), + help = "Override default configuration directory", + ) + parser.add_option("", "--server", dest = "server", + metavar = "HOSTNAME:PORT", + default = "www.ospace.net:9080", + help = "Outer Space server location" + ) + parser.add_option("", "--login", dest = "login", + metavar = "LOGIN", + default = None, + help = "Login name of the AI player.", + ) + parser.add_option("", "--password", dest = "password", + metavar = "PASSWORD", + default = None, + help = "Corresponding password of the AI player.", + ) + parser.add_option("", "--ai", dest = "ai", + metavar = "AI", + default = None, + help = "Type of the AI applied." + ) + parser.add_option("", "--game", dest = "game", + metavar = "NAME", + default = 'Alpha', + help = "Name of game to which the AI belongs", + ) + + options, args = parser.parse_args() + + if args: + parser.error("No additional arguments are supported") + + runAIClient(options, args) Modified: branches/singleplayer/client-ai/ai_osc.py =================================================================== --- branches/singleplayer/client-ai/ai_osc.py 2012-06-09 06:21:25 UTC (rev 328) +++ branches/singleplayer/client-ai/ai_osc.py 2012-06-09 08:27:28 UTC (rev 329) @@ -1,48 +0,0 @@ -#!/usr/bin/python - -# -# Copyright 2001 - 2011 Ludek Smid [http://www.ospace.net/] -# -# This file is part of IGE - Outer Space. -# -# IGE - Outer Space is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# IGE - Outer Space is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with IGE - Outer Space; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# - -# tweak PYTHONPATH -import sys -import os - -basepath = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - -sys.path.insert(0, os.path.join(basepath, "client-pygame/lib")) -sys.path.insert(0, os.path.join(basepath, "client-pygame/lib/osci")) - -for item in ("libsrvr", "server/lib"): - path = os.path.join(basepath, item) - if os.path.exists(path): - sys.path.insert(0, path) - break - -#configure gc -#import gc -#gc.set_debug(gc.DEBUG_STATS | gc.DEBUG_COLLECTABLE | gc.DEBUG_UNCOLLECTABLE | -# gc.DEBUG_INSTANCES | gc.DEBUG_OBJECTS) - -# start application -import ai_main - -# profiling -#import profile -#profile.run('import osci.main', 'profile.txt') Modified: branches/singleplayer/client-ai/ai_parser.py =================================================================== --- branches/singleplayer/client-ai/ai_parser.py 2012-06-09 06:21:25 UTC (rev 328) +++ branches/singleplayer/client-ai/ai_parser.py 2012-06-09 08:27:28 UTC (rev 329) @@ -17,142 +17,147 @@ # along with Outer Space; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +import json import os import shutil import tarfile from ige import log +class AIRecord: + def __init__(self): + pass + + def __getattr__(self, name): + return None + + def __repr__(self): + return str(self.__dict__) + +class AIRecordEncoder(json.JSONEncoder): + def default(self, obj): + if isinstance(obj, AIRecord): + return {'__class__':'AIRecord', '__value__':obj.__dict__} + else: + return json.JSONEncoder.default(obj) + +def aiRecordDecoder(class_dict): + if '__class__' in class_dict: + if class_dict['__class__'] == 'AIRecord': + obj = AIRecord() + obj.__dict__ = class_dict['__value__'] + return obj + # else + return class_dict + class AIList: """ Class used to parse and work with list of ai players [which is then used by run_ai.py]. - It creates file in config directory, named ais_list where each line is - one player, and the format is - - login password used_ai_script galaxy_name + It creates file in config directory, named ais_list.<gameName> which + contains json representation of list of AI players of the particular + game. - Data dumps used by ai clients are recommended to save to the directory - configDir/ai_data/galaxy_name/ + Data dumps used by ai clients are recommended to be saved to the directory + <configDir>/ai_data/<gameName>/<galaxy_name>/ to be processed correctly. """ - def __init__(self, configDir): + def __init__(self, configDir, gameName): self.configDir = configDir - self.lines = {} + self.gameName = gameName + self.records = [] # parsing the file + self.listname = "ais_list.{0}".format(self.gameName) try: - listfile = open(os.path.join(self.configDir, "ais_list"), "r") - for row in listfile: - line = row.strip().split(" ") - if len(line) == 3: - self.lines.update({line[0]:tuple([line[1], line[2]])}) - elif len(line) == 4: - self.lines.update({line[0]:tuple([line[1], line[2], line[3]])}) - else: - continue - listfile.close() + self.records = json.load(open(os.path.join(self.configDir, self.listname), "r"), object_hook=aiRecordDecoder) except Exception, e: - listfile = open(os.path.join(self.configDir, "ais_list"), "a") + listfile = open(os.path.join(self.configDir, self.listname), "a") listfile.close() - + + def _save(self): + json.dump(self.records, open(os.path.join(self.configDir, self.listname), "w"), cls=AIRecordEncoder) + def add(self, login, password, aiType): """ It adds new line to the ais_list. Now without galaxy_name, because game doesn't know yet, to which galaxy will the player go. """ - self.lines.update({login:(password, aiType, None)}) - listfile = open(os.path.join(self.configDir, "ais_list"), "w") - for item in self.lines: - listfile.write(item + ' ' + reduce(lambda x,y: str(x) + ' ' + str(y), self.lines[item]) + '\n') - return + record = AIRecord() + record.login = login + record.password = password + record.aiType = aiType + self.records.append(record) + self._save() def remove(self, login): """ Removes the line associated with login. """ - try: - del self.lines[login] - except KeyError, e: - pass - listfile = open(os.path.join(self.configDir, "ais_list"), "w") - for item in self.lines: - listfile.write(item + ' ' + reduce(lambda x,y: str(x) + ' ' + str(y), self.lines[item]) + '\n') - listfile.close() - return + for record in self.records[:]: + if record.gameName == self.gameName and record.login == login: + self.records.remove(record) + self._save() def getAll(self): - return self.lines.items() + return self.records def getLogins(self): - return self.lines.keys() + return self.records def removeAll(self): - self.lines = {} - listfile = open(os.path.join(self.configDir, "ais_list"), "w") - listfile.close() + self.records = [] + self._save() def setGalaxy(self, login, galaxyName): - """ Add [or change] the galaxy information to the line associated + """ Add [or change] the galaxy information to the record associated with login. """ - password, aiType, galaxy = self.lines[login] - self.lines.update({login:(password, aiType, galaxyName)}) + for record in self.records: + if record.login == login: + record.galaxyName = galaxyName try: - os.mkdir(os.path.join(self.configDir, "ai_data", galaxyName)) + os.makedirs(os.path.join(self.configDir, "ai_data", self.gameName, galaxyName)) except OSError: pass - listfile = open(os.path.join(self.configDir, "ais_list"), "w") - for item in self.lines: - listfile.write(item + ' ' + reduce(lambda x,y: str(x) + ' ' + str(y), self.lines[item]) + '\n') - listfile.close() + self._save() return def finishGalaxy(self, galaxyName): """ Removes galaxy directory, and all player data contained within. """ - for item in os.listdir(os.path.join(self.configDir, 'ai_data', galaxyName)): - os.remove(os.path.join(self.configDir, 'ai_data', galaxyName, item)) - os.rmdir(os.path.join(self.configDir, 'ai_data', galaxyName)) + shutil.rmtree(os.path.join(self.configDir, 'ai_data', self.gameName, galaxyName)) return def backup(self, backupPath): """ Creates bzip2 archive of ais_list file and ai_data directory """ - log.debug('Creating backup %s-ais.osbackup' % backupPath) - tar = tarfile.open('%s-ais.osbackup' % backupPath, 'w:bz2') - tar.add(os.path.join(self.configDir, 'ais_list')) - tar.add(os.path.join(self.configDir, 'ai_data')) + log.debug('Creating backup {0}-ais.osbackup'.format(backupPath)) + tar = tarfile.open('{0}-ais.osbackup'.format(backupPath), 'w:bz2') + tar.add(os.path.join(self.configDir, self.listname)) + tar.add(os.path.join(self.configDir, 'ai_data', self.gameName)) tar.close() def restore(self, backupPath): """ Extracts data of the ai players, as well as the ais_list file. """ - os.remove(os.path.join(self.configDir, 'ais_list')) - shutil.rmtree(os.path.join(self.configDir, 'ai_data')) - log.message('Restoring AI backup %s' % backupPath) + os.remove(os.path.join(self.configDir, self.listname)) + shutil.rmtree(os.path.join(self.configDir, 'ai_data', self.gameName)) + log.message('Restoring AI backup {0}'.format(backupPath)) tar = tarfile.open(backupPath, 'r:bz2') tar.extractall() tar.close() - self.lines = {} + self.records = [] # parsing the file try: - listfile = open(os.path.join(self.configDir, "ais_list"), "r") - for row in listfile: - line = row.strip().split(" ") - if len(line) == 3: - self.lines.update({line[0]:tuple([line[1], line[2]])}) - elif len(line) == 4: - self.lines.update({line[0]:tuple([line[1], line[2], line[3]])}) - else: - continue - listfile.close() + self.records = json.load(open(os.path.join(self.configDir, self.listname), "r"), object_hook=aiRecordDecoder) except Exception, e: - listfile = open(os.path.join(self.configDir, "ais_list"), "a") + listfile = open(os.path.join(self.configDir, self.listname), "a") listfile.close() - log.message('AI backup restored') \ No newline at end of file + log.message('AI backup restored') + Modified: branches/singleplayer/client-pygame/lib/osci/StarMapWidget.py =================================================================== --- branches/singleplayer/client-pygame/lib/osci/StarMapWidget.py 2012-06-09 06:21:25 UTC (rev 328) +++ branches/singleplayer/client-pygame/lib/osci/StarMapWidget.py 2012-06-09 08:27:28 UTC (rev 329) @@ -545,11 +545,10 @@ self.setPosition = 0 self.currX = anyX self.currY = anyY - self.miniMap.precompute() # self dirty flag self.repaintMap = 1 - + def getPirateFameCost(self, playerID, systemID, numPiratePlanets, pirates): mod = 1 system = client.get(systemID, noUpdate = 1) @@ -1048,7 +1047,7 @@ centralPlanet = client.get(player.planets[0]) govPCR = player.govPwrCtrlRange player.stats.storPop, player.govPwr - for step in xrange(100, max(Rules.minMoraleTrgt-1, int(107.5-37.5*player.stats.storPop/player.govPwr) - 1) , -10): + for step in xrange(100, max(int(Rules.minMoraleTrgt)-1, int(107.5-37.5*player.stats.storPop/player.govPwr) - 1) , -10): moraleColor = res.getMoraleColors(step) centralX = int((centralPlanet.x - currX) * scale) + centerX centralY = maxY - (int((centralPlanet.y - currY) * scale) + centerY) @@ -1762,6 +1761,8 @@ # Ctrl+S - Toggle drawing scanners elif evt.unicode == u'\x13' and pygame.key.get_mods() & KMOD_CTRL: self.toggleHotbuttons('scanner') + elif evt.unicode == u'\x14' and pygame.key.get_mods() & KMOD_CTRL: + client.killServer() # Reserve CTRL-V,X,and Z for paste, cut, and undo (future editor support) # ==== Else ==== else: Modified: branches/singleplayer/client-pygame/lib/osci/client.py =================================================================== --- branches/singleplayer/client-pygame/lib/osci/client.py 2012-06-09 06:21:25 UTC (rev 328) +++ branches/singleplayer/client-pygame/lib/osci/client.py 2012-06-09 08:27:28 UTC (rev 329) @@ -18,6 +18,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +import multiprocessing import xmlrpclib from igeclient import IClient, IClientDB @@ -26,6 +27,8 @@ from ige.IDataHolder import IDataHolder import ige, gdata, osci, math, time from ige import log +from ige.Const import SINGLE_GAME, SINGLE_LOGIN, SINGLE_PASSWORD +from run_ai import OptionsAIRunner, runAIs # module globals cmdProxy = None @@ -38,6 +41,9 @@ nonexistingObj = {} options = None galaxer = None +single = False +aisProc = None +gameName = None def initialize(aServer, aCallbackObj, anOptions): global callbackObj, server, options, galaxer @@ -52,12 +58,12 @@ cmdProxy = None initCmdProxy(options.heartbeat) -def initCmdProxy(keepAliveTime): +def initCmdProxy(keepAliveTime, forced=False, http_proxy=True): global cmdProxy, server - if not cmdProxy: + if not cmdProxy or forced: callbackObj.onInitConnection() proxy = None - if gdata.config.proxy.http != None: + if gdata.config.proxy.http != None and http_proxy: proxy = gdata.config.proxy.http cmdProxy = IClient.IClient(server, proxy, msgHandler, idleHandler, 'OSClient/%s' % ige.version.versionString, keepAliveTime) callbackObj.onConnInitialized() @@ -65,6 +71,12 @@ ## Authentication def login(gameid, login, password): + global gameName + if single: + gameid = SINGLE_GAME + login = SINGLE_LOGIN + password = SINGLE_PASSWORD + gameName = gameid initCmdProxy(options.heartbeat) cmdProxy.connect(login) if gdata.config.client.keepAlive != None: @@ -128,9 +140,43 @@ token = cmdProxy.getToken() galaxerData = galaxer.setPlayerPreference(token, galType) return galaxerData - - ## Message handler +## Part responsible for singleplayer switching +def setSingleplayer(): + global callbackObj, server, options, galaxer, single, aisProc + single = True + server = 'localhost:9080' + galaxer = xmlrpclib.ServerProxy('http://localhost:9081') + initCmdProxy(keepAliveTime=options.heartbeat, forced=True, http_proxy=False) + opt, args = OptionsAIRunner(), [] + opt.configDir = options.configDir + +def tickSingleplayer(turns=1): + global aisProc + if not single: + return + if aisProc: + aisProc.join() + cmdProxy.processTurns(turns) + time.sleep(0.5) + updateDatabase() + opt, args = OptionsAIRunner(), [] + opt.configDir = options.configDir + aisProc = multiprocessing.Process(target=runAIs, args=(opt, args)) + aisProc.start() + +def finishGalaxer(): + if not single: + setSingleplayer() + galaxer.logout() + +def finishServer(): + if not single: + setSingleplayer() + cmdProxy.shutdown() + +## Message handler + def msgHandler(mid, data): if ignoreMsgs.has_key(mid): log.debug('OSClient', 'ignoring message', mid, data) Modified: branches/singleplayer/client-pygame/lib/osci/dialog/GalaxerDlg.py =================================================================== --- branches/singleplayer/client-pygame/lib/osci/dialog/GalaxerDlg.py 2012-06-09 06:21:25 UTC (rev 328) +++ branches/singleplayer/client-pygame/lib/osci/dialog/GalaxerDlg.py 2012-06-09 08:27:28 UTC (rev 329) @@ -32,7 +32,7 @@ self.app = app self.createUI() self.galaxerInfo = client.getGalaxerData() - + def display(self, caller = None): self.caller = caller if self.show(): Modified: branches/singleplayer/client-pygame/lib/osci/dialog/LoginDlg.py =================================================================== --- branches/singleplayer/client-pygame/lib/osci/dialog/LoginDlg.py 2012-06-09 06:21:25 UTC (rev 328) +++ branches/singleplayer/client-pygame/lib/osci/dialog/LoginDlg.py 2012-06-09 08:27:28 UTC (rev 329) @@ -17,6 +17,7 @@ # along with Outer Space; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +import os import pygameui as ui from osci import client, gdata, res @@ -27,6 +28,7 @@ from OptionsDlg import OptionsDlg import binascii from ige import log +from ige.Const import SINGLE_LOGIN, SINGLE_PASSWORD from igeclient.IClient import IClientException class LoginDlg: @@ -37,6 +39,7 @@ self.confirmDlg = ConfirmDlg(app) self.firstlogin = True self.versionChecked = False + self.single = False self.createUI() def display(self, caller = None, message = None): @@ -52,6 +55,7 @@ self.gameIDs = {"Alpha": "Alpha"} # show / hide new account button self.win.vCreate.visible = gdata.config.game.accountcreated == None + self.win.setTagAttr('values', 'visible', not self.single) # fill in default values if gdata.config.game.lastlogin != None: self.win.vLogin.text = gdata.config.game.lastlogin @@ -87,7 +91,16 @@ gameID = self.win.vUniverse.data self.doLogin(gameID,login,password) + def onSingle(self, widget, action, data): + self.single = not self.single + self.display() + + def onLogin(self, widget, action, data): + if self.single: + # this will overrule the data set on the next lines, + # single defaults will be used instead + client.setSingleplayer() self.firstlogin = False login = self.win.vLogin.text password = self.win.vPassword.text @@ -100,19 +113,20 @@ result = client.login(gameID, login, password) self.win.hide() if result == 1: - gdata.config.game.lastlogin = login - # TODO: remove in 0.6 - gdata.config.game.lastpassword = None - # - if gdata.savePassword: + if not self.single: + gdata.config.game.lastlogin = login + # TODO: remove in 0.6 + gdata.config.game.lastpassword = None + # + if gdata.savePassword: + gdata.config.game.lastpasswordcrypted = binascii.b2a_base64(password).strip() + else: + gdata.config.game.lastpasswordcrypted = None + gdata.config.game.lastgameid = gameID + gdata.config.game.accountcreated = 1 + # write configuration + gdata.config.save() gdata.config.game.lastpasswordcrypted = binascii.b2a_base64(password).strip() - else: - gdata.config.game.lastpasswordcrypted = None - gdata.config.game.lastgameid = gameID - gdata.config.game.accountcreated = 1 - # write configuration - gdata.config.save() - gdata.config.game.lastpasswordcrypted = binascii.b2a_base64(password).strip() # check version log.debug('Comparing server and client versions', client.serverVersion, version) if client.serverVersion != version and not self.versionChecked: @@ -187,13 +201,14 @@ modal = 1, movable = 0, title = _('Outer Space Login'), - rect = ui.Rect((w - 424) / 2, (h - 144) / 2, 424, 144), + rect = ui.Rect((w - 424) / 2, (h - 164) / 2, 424, 164), layoutManager = ui.SimpleGridLM(), tabChange = True, ) self.win.subscribeAction('*', self) ui.Label(self.win, text = _('Universe'), + tags = ['values'], align = ui.ALIGN_E, layout = (5, 0, 6, 1) ) @@ -208,27 +223,31 @@ layout = (5, 1, 6, 1) ) ui.Entry(self.win, id = 'vLogin', + tags = ['values'], align = ui.ALIGN_W, layout = (11, 1, 10, 1), orderNo = 1 ) ui.Label(self.win, + tags = ['values'], text = _('Password'), align = ui.ALIGN_E, layout = (5, 2, 6, 1), ) ui.Entry(self.win, id = 'vPassword', + tags = ['values'], align = ui.ALIGN_W, showChar = '*', layout = (11, 2, 10, 1), orderNo = 2 ) ui.Button(self.win, layout = (11, 3, 10, 1), text = _("Options"), action = "onOptions", id = "vOptions") - ui.Button(self.win, layout = (11, 4, 10, 1), text = _("New account"), + ui.Button(self.win, layout = (11, 4, 10, 1), text = _("New online account"), action = "onCreateAccount", id = "vCreate") - ui.Title(self.win, layout = (0, 5, 11, 1), id = 'vMessage', align = ui.ALIGN_W) - ui.TitleButton(self.win, layout = (11, 5, 5, 1), text = _('Exit'), action = 'onCancel') - loginBtn = ui.TitleButton(self.win, layout = (16, 5, 5, 1), text = _('Login'), action = 'onLogin') + ui.Check(self.win, layout = (13, 5, 8, 1), id = "vSingle", text = _("Singleplayer"), action = "onSingle") + ui.Title(self.win, layout = (0, 6, 11, 1), id = 'vMessage', align = ui.ALIGN_W) + ui.TitleButton(self.win, layout = (11, 6, 5, 1), text = _('Exit'), action = 'onCancel') + loginBtn = ui.TitleButton(self.win, layout = (16, 6, 5, 1), text = _('Login'), action = 'onLogin') ui.Label(self.win, layout = (0, 0, 5, 4), icons = ((res.loginLogoImg, ui.ALIGN_W),)) self.win.acceptButton = loginBtn # Universe selection Modified: branches/singleplayer/client-pygame/lib/osci/dialog/MainGameDlg.py =================================================================== --- branches/singleplayer/client-pygame/lib/osci/dialog/MainGameDlg.py 2012-06-09 06:21:25 UTC (rev 328) +++ branches/singleplayer/client-pygame/lib/osci/dialog/MainGameDlg.py 2012-06-09 08:27:28 UTC (rev 329) @@ -36,6 +36,7 @@ from ConfirmDlg import ConfirmDlg from OptionsDlg import OptionsDlg from SearchDlg import SearchDlg +from SingleOptions import SingleOptionsDlg import ProblemsDlg import DiplomacyDlg import EmpireOverviewDlg @@ -69,6 +70,7 @@ self.galaxyRestartDlg = GalaxyRestartDlg(self.app) self.planetsAnalysisDlg = PlanetsAnalysisDlg(app) self.fleetsAnalysisDlg = FleetsAnalysisDlg(app) + self.singleOptionsDlg = SingleOptionsDlg(app) self.mapWidget = None self.createUI() self.centered = 0 @@ -76,6 +78,8 @@ def display(self): gdata.showBackground = 0 gdata.mainGameDlg = self + self.win.setTagAttr('single', 'visible', client.single) + self.win.setTagAttr('multi', 'visible', not client.single) self.win.show() # register for updates gdata.updateDlgs.append(self) @@ -99,6 +103,10 @@ if self in gdata.updateDlgs: gdata.updateDlgs.remove(self) + def onLogout(self, widget, action, data): + self.app.setStatus(_('Logging out...')) + self.app.localExit() + def onQuit(self, widget, action, data): self.app.setStatus(_('Logging out and exitting...')) self.app.exit() @@ -162,6 +170,9 @@ def onSearch(self, widget, action, data): self.searchDlg.display() + def onSingleOptions(self, widget, action, data): + self.singleOptionsDlg.display() + def onStats(self, widget, action, data): for galaxyID in client.getPlayer().galaxies: url = 'http://%s/%s/galaxy%d.html' % ( @@ -196,7 +207,7 @@ def onResignConfirmed(self): client.cmdProxy.resign(client.getPlayerID()) client.db.clear() - self.app.exit() + self.app.localExit() def onRestartConfirmed(self, imperatorMsg): self.win.setStatus(_('Galaxy restart in progress...')) @@ -207,8 +218,18 @@ client.db.clear() client.cmdProxy.msgHandler = oldMsgHandler self.hide() - self.app.exit() + self.app.localExit() + def onNextTurn(self, widget, action, data): + turns = self.win.vTurns.text + try: + turns = int(turns) + if turns < 1: + raise ValueError + client.tickSingleplayer(turns) + except ValueError: + self.win.setStatus(_('Number of turns is in invalid format...')) + def update(self,configUpdated=False): self.galaxyRestart(None, None, False) player = client.getPlayer() @@ -331,12 +352,27 @@ ) ui.ActiveLabel(self.win, id = "vSponsor", + tags = ['multi'], align = ui.ALIGN_W, icons = [(pygame.image.load("res/sponsor_logo_small.png"), ui.ALIGN_E)], layout = (lw - 12, lh - 1, 8, 1), action = "onSponsor", statustip = _("Server sponsored by K2 Software"), ) + ui.Entry(self.win, + layout = (lw-12, lh - 1, 3, 1), + id = 'vTurns', + text = '1', + align = ui.ALIGN_NONE, + tags = ['single'], + ) + ui.Button(self.win, + layout = (lw - 9, lh - 1, 5, 1), + text = _('Next turn'), + align = ui.ALIGN_NONE, + tags = ['single'], + action = 'onNextTurn', + ) ui.Label(self.win, id = 'vTurn', align = ui.ALIGN_E, @@ -367,9 +403,7 @@ self.app.statusBar = self.win.vStatus self.app.setStatus(_('Ready.')) # system menu - self.systemMenu = ui.Menu(self.app, title = _("Menu"), - width = 5, - items = [ + systemItems = [ ui.Item(_("Find system"), action = "onSearch", hotkey = u'\x66'), # F ui.Item(_("Statistics"), action = "onStats", hotkey = u'\x73'), # S ui.Item(_("Save Starmap"), action = "onSaveStarmap", hotkey = u'\x76'), # V @@ -378,8 +412,16 @@ ui.Item(_("--------"), enabled = False), ui.Item(_("Resign"), action = "onResign"), # no hotkey ui.Item(_("--------"), enabled = False), + ui.Item(_("Logout"), action = "onLogout"), ui.Item(_("Quit"), action = "onQuit", hotkey = u'\x71'), # Q - ] + ] + if client.single: + systemItems.insert(0, ui.Item(_("Single options"), action = "onSingleOptions")) + systemItems.insert(1, ui.Item(_("--------"), enabled = False)) + + self.systemMenu = ui.Menu(self.app, title = _("Menu"), + width = 5, + items =systemItems ) self.systemMenu.subscribeAction("*", self) self.systemFleetMenu = ui.Menu(self.app, title = _("Fleets"), Modified: branches/singleplayer/client-pygame/lib/osci/dialog/NewAccountDlg.py =================================================================== --- branches/singleplayer/client-pygame/lib/osci/dialog/NewAccountDlg.py 2012-06-09 06:21:25 UTC (rev 328) +++ branches/singleplayer/client-pygame/lib/osci/dialog/NewAccountDlg.py 2012-06-09 08:27:28 UTC (rev 329) @@ -44,6 +44,10 @@ self.win.hide() def show(self): + if client.single: + self.win.vBook.text = _('New game') + else: + self.win.vBook.text = _('Book position') positions = client.cmdProxy.getStartingPositions() items = [] for objID, name, posType in positions: @@ -133,7 +137,7 @@ self.win.subscribeAction('*', self) ui.Label(self.win, layout = (0, 10, 5, 1), text = _("VIP Password:")) ui.Entry(self.win, layout = (5, 10, 5, 1), id = 'vPassword', align = ui.ALIGN_W, showChar = '*', orderNo = 1 ) - ui.TitleButton(self.win, layout = (13, 10, 8, 1), text = _('Book position'), action = 'onGalaxer') + ui.TitleButton(self.win, layout = (13, 10, 8, 1), id = 'vBook', text = _('Book position'), action = 'onGalaxer') ui.Title(self.win, layout = (0, 11, 13, 1), id = 'vStatusBar', align = ui.ALIGN_W) ui.TitleButton(self.win, layout = (13, 11, 4, 1), text = _('Exit'), action = 'onCancel') ui.TitleButton(self.win, layout = (17, 11, 4, 1), text = _('Select'), action = 'onSelect') Modified: branches/singleplayer/client-pygame/lib/osci/main.py =================================================================== --- branches/singleplayer/client-pygame/lib/osci/main.py 2012-06-09 06:21:25 UTC (rev 328) +++ branches/singleplayer/client-pygame/lib/osci/main.py 2012-06-09 08:27:28 UTC (rev 329) @@ -32,6 +32,7 @@ import re import binascii from optparse import OptionParser +import multiprocessing # log initialization log.message("Starting Outer Space Client", ige.version.versionStringFull) @@ -79,11 +80,32 @@ default = "http://www.ospace.net:9081", help = "Outer Space galaxy booking system location" ) +parser.add_option("", "--local", dest = "local", + action = "store_true", + metavar = "LOCAL", + default = False, + help = "Setting on local mode [no connection to the remote server]" +) options, args = parser.parse_args() if args: parser.error("No additional arguments are supported") +# start local server and local galaxer +from run import OptionsServer, runServer +optionsServer, argsServer = OptionsServer(), [] +optionsServer.configDir = options.configDir +optionsServer.mode = 2 +serverProc = multiprocessing.Process(target=runServer, args=(optionsServer, args)) +serverProc.start() +from run_galaxer import OptionsGalaxer, runGalaxer +optionsGalaxer, argsGalaxer = OptionsGalaxer(), [] +optionsGalaxer.configDir = options.configDir +optionsGalaxer.server = 'localhost:9080' +optionsGalaxer.address = 'localhost:9081' +optionsGalaxer.local = True +galaxerProc = multiprocessing.Process(target=runGalaxer, args=(optionsGalaxer, args)) +galaxerProc.start() # splash screen background = None backgroundOffset = None @@ -161,292 +183,328 @@ if not os.path.exists(options.configDir): os.makedirs(options.configDir) -# parse configuration -import gdata -#from ConfigParser import ConfigParser +running = 1 +first = True +while running: + if not first: + reload(osci) + # parse configuration + if first: + import gdata + else: + reload(gdata) + #from ConfigParser import ConfigParser -gdata.config = Config(os.path.join(options.configDir, options.configFilename)) + gdata.config = Config(os.path.join(options.configDir, options.configFilename)) -# default configuration -gdata.config.game.server = options.server -gdata.config.galaxer.server = options.galaxer + # default configuration + if not options.local: + gdata.config.game.server = options.server + gdata.config.galaxer.server = options.galaxer + else: + gdata.config.game.server = "localhost:9080" + gdata.config.galaxer.server = "http://localhost:9081" + + if gdata.config.client.language == None: + gdata.config.client.language = 'en' -if gdata.config.client.language == None: - gdata.config.client.language = 'en' + language = gdata.config.client.language -language = gdata.config.client.language + if gdata.config.defaults.minfleetsymbolsize == None: + gdata.config.defaults.minfleetsymbolsize = 4 -if gdata.config.defaults.minfleetsymbolsize == None: - gdata.config.defaults.minfleetsymbolsize = 4 + if gdata.config.defaults.minplanetsymbolsize == None: + gdata.config.defaults.minplanetsymbolsize = 5 -if gdata.config.defaults.minplanetsymbolsize == None: - gdata.config.defaults.minplanetsymbolsize = 5 + if gdata.config.defaults.maxfleetsymbolsize == None: + gdata.config.defaults.maxfleetsymbolsize = 0 -if gdata.config.defaults.maxfleetsymbolsize == None: - gdata.config.defaults.maxfleetsymbolsize = 0 + if gdata.config.defaults.maxplanetsymbolsize == None: + gdata.config.defaults.maxplanetsymbolsize = 0 + + import gettext + try: + tran = gettext.translation('OSPACE', 'res', languages = [language]) + except IOError: + log.warning('OSCI', 'Cannot find catalog for', language) + log.message('OSCI', 'Installing null translations') + tran = gettext.NullTranslations() -if gdata.config.defaults.maxplanetsymbolsize == None: - gdata.config.defaults.maxplanetsymbolsize = 0 - -import gettext -try: - tran = gettext.translation('OSPACE', 'res', languages = [language]) -except IOError: - log.warning('OSCI', 'Cannot find catalog for', language) - log.message('OSCI', 'Installing null translations') - tran = gettext.NullTranslations() + tran.install(unicode = 1) -tran.install(unicode = 1) + # read Highlights + if gdata.config.defaults.colors != None: + for coldef in gdata.config.defaults.colors.split(' '): + m = re.match('(\d+):(0[xX].*?),(0[xX].*?),(0[xX].*)',coldef) + if m != None : + id = int(m.group(1)) + red = min(int(m.group(2),16),255) + green = min(int(m.group(3),16),255) + blue = min(int(m.group(4),16),255) + gdata.playersHighlightColors[id] = (red,green,blue) + else: + log.warning('OSCI','Unrecognized highlight definition :',coldef) + # read Object Keys + if gdata.config.defaults.objectkeys != None: + for objectkey in gdata.config.defaults.objectkeys.split(' '): + m = re.match('(\d+):(\d+)',objectkey) + if m != None : + key = int(m.group(1)) + objid = int(m.group(2)) + gdata.objectFocus[key] = objid + else: + log.warning('OSCI','Unrecognized object key definition :',objectkey) -# read Highlights -if gdata.config.defaults.colors != None: - for coldef in gdata.config.defaults.colors.split(' '): - m = re.match('(\d+):(0[xX].*?),(0[xX].*?),(0[xX].*)',coldef) - if m != None : - id = int(m.group(1)) - red = min(int(m.group(2),16),255) - green = min(int(m.group(3),16),255) - blue = min(int(m.group(4),16),255) - gdata.playersHighlightColors[id] = (red,green,blue) - else: - log.warning('OSCI','Unrecognized highlight definition :',coldef) -# read Object Keys -if gdata.config.defaults.objectkeys != None: - for objectkey in gdata.config.defaults.objectkeys.split(' '): - m = re.match('(\d+):(\d+)',objectkey) - if m != None : - key = int(m.group(1)) - objid = int(m.group(2)) - gdata.objectFocus[key] = objid - else: - log.warning('OSCI','Unrecognized object key definition :',objectkey) + #initialize pygame and prepare screen + if (gdata.config.defaults.sound == "yes") or (gdata.config.defaults.music == "yes"): + pygame.mixer.pre_init(44100, -16, 2, 4096) -#initialize pygame and prepare screen -if (gdata.config.defaults.sound == "yes") or (gdata.config.defaults.music == "yes"): - pygame.mixer.pre_init(44100, -16, 2, 4096) + os.environ['SDL_VIDEO_ALLOW_SCREENSAVER'] = '1' + os.environ['SDL_DEBUG'] = '1' + pygame.init() -os.environ['SDL_VIDEO_ALLOW_SCREENSAVER'] = '1' -os.environ['SDL_DEBUG'] = '1' -pygame.init() + # step by step initialization + #pygame.display.init() + #pygame.font.init() -# step by step initialization -#pygame.display.init() -#pygame.font.init() + # flags = HWSURFACE | DOUBLEBUF | FULLSCREEN + # flags = HWSURFACE | FULLSCREEN + flags = SWSURFACE -# flags = HWSURFACE | DOUBLEBUF | FULLSCREEN -# flags = HWSURFACE | FULLSCREEN -flags = SWSURFACE + isHWSurface = 0 -isHWSurface = 0 + if gdata.config.display.flags != None: + strFlags = gdata.config.display.flags.split(' ') + flags = 0 + if 'swsurface' in strFlags: flags |= SWSURFACE + if 'hwsurface' in strFlags: + flags |= HWSURFACE + isHWSurface = 1 + if 'doublebuf' in strFlags: flags |= DOUBLEBUF + if 'fullscreen' in strFlags: flags |= FULLSCREEN -if gdata.config.display.flags != None: - strFlags = gdata.config.display.flags.split(' ') - flags = 0 - if 'swsurface' in strFlags: flags |= SWSURFACE - if 'hwsurface' in strFlags: - flags |= HWSURFACE - isHWSurface = 1 - if 'doublebuf' in strFlags: flags |= DOUBLEBUF - if 'fullscreen' in strFlags: flags |= FULLSCREEN + gdata.scrnSize = (800, 600) + if gdata.config.display.resolution != None: + width, height = gdata.config.display.resolution.split('x') + gdata.scrnSize = (int(width), int(height)) -gdata.scrnSize = (800, 600) -if gdata.config.display.resolution != None: - width, height = gdata.config.display.resolution.split('x') - gdata.scrnSize = (int(width), int(height)) + if gdata.config.display.depth == None: + # guess best depth + bestdepth = pygame.display.mode_ok(gdata.scrnSize, flags) + else: + bestdepth = int(gdata.config.display.depth) -if gdata.config.display.depth == None: - # guess best depth - bestdepth = pygame.display.mode_ok(gdata.scrnSize, flags) -else: - bestdepth = int(gdata.config.display.depth) + # initialize screen + screen = pygame.display.set_mode(gdata.scrnSize, flags, bestdepth) + log.debug('OSCI', 'Driver:', pygame.display.get_driver()) + log.debug('OSCI', 'Using depth:', bestdepth) + log.debug('OSCI', 'Display info:', pygame.display.Info()) -# initialize screen -screen = pygame.display.set_mode(gdata.scrnSize, flags, bestdepth) -log.debug('OSCI', 'Driver:', pygame.display.get_driver()) -log.debug('OSCI', 'Using depth:', bestdepth) -log.debug('OSCI', 'Display info:', pygame.display.Info()) + pygame.mouse.set_visible(1) -pygame.mouse.set_visible(1) + pygame.display.set_caption(_('Outer Space %s') % ige.version.versionString) -pygame.display.set_caption(_('Outer Space %s') % ige.version.versionString) + # set icon + pygame.display.set_icon(pygame.image.load('res/icon48.png').convert_alpha()) -# set icon -pygame.display.set_icon(pygame.image.load('res/icon48.png').convert_alpha()) + # load cursor + cursorImg = pygame.image.load('res/cursor.png').convert_alpha() -# load cursor -cursorImg = pygame.image.load('res/cursor.png').convert_alpha() -drawBackground() -pygame.display.flip() + pygame.event.clear() + drawBackground() + pygame.display.flip() -# UI stuff -import pygameui as ui + # UI stuff + if first: + import pygameui as ui + else: + reload(ui) -theme = "green" -if gdata.config.client.theme != None: - theme = gdata.config.client.theme -ui.SkinableTheme.enableMusic(gdata.config.defaults.music == "no") -ui.SkinableTheme.enableSound(gdata.config.defaults.sound == "yes") -ui.SkinableTheme.setSkin(os.path.join("res/themes", theme)) -ui.SkinableTheme.loadMusic(gdata.config.defaults.mymusic) -if gdata.config.defaults.musicvolume: - ui.SkinableTheme.setMusicVolume(float(gdata.config.defaults.musicvolume)/ 100.0) -if gdata.config.defaults.soundvolume: - ui.SkinableTheme.setVolume(float(gdata.config.defaults.soundvolume) / 100.0) + theme = "green" + if gdata.config.client.theme != None: + theme = gdata.config.client.theme + ui.SkinableTheme.enableMusic(gdata.config.defaults.music == "no") + ui.SkinableTheme.enableSound(gdata.config.defaults.sound == "yes") + ui.SkinableTheme.setSkin(os.path.join("res/themes", theme)) + ui.SkinableTheme.loadMusic(gdata.config.defaults.mymusic) + if gdata.config.defaults.musicvolume: + ui.SkinableTheme.setMusicVolume(float(gdata.config.defaults.musicvolume)/ 100.0) + if gdata.config.defaults.soundvolume: + ui.SkinableTheme.setVolume(float(gdata.config.defaults.soundvolume) / 100.0) -gdata.sevColors[gdata.CRI] = (ui.SkinableTheme.themeCritical) -gdata.sevColors[gdata.MAJ] = (ui.SkinableTheme.themeMajor) -gdata.sevColors[gdata.MIN] = (ui.SkinableTheme.themeMinor) -gdata.sevColors[gdata.NONE] = (ui.SkinableTheme.themeNone) -gdata.sevColors[gdata.DISABLED] = (ui.SkinableTheme.themeDisabled) + gdata.sevColors[gdata.CRI] = (ui.SkinableTheme.themeCritical) + gdata.sevColors[gdata.MAJ] = (ui.SkinableTheme.themeMajor) + gdata.sevColors[gdata.MIN] = (ui.SkinableTheme.themeMinor) + gdata.sevColors[gdata.NONE] = (ui.SkinableTheme.themeNone) + gdata.sevColors[gdata.DISABLED] = (ui.SkinableTheme.themeDisabled) -app = ui.Application(update, theme = ui.SkinableTheme) -app.windowSurfaceFlags = SWSURFACE | SRCALPHA -gdata.app = app + app = ui.Application(update, theme = ui.SkinableTheme) + app.windowSurfaceFlags = SWSURFACE | SRCALPHA + gdata.app = app -# resources -import res + # resources + import res -res.initialize() + res.initialize() -# load resources -res.loadResources() + # load resources + res.loadResources() -# client -import client, handler -from igeclient.IClient import IClientException -client.initialize(gdata.config.game.server, handler, options) + # client + if first: + import client, handler + from igeclient.IClient import IClientException + else: + reload(client) + reload(handler) + client.initialize(gdata.config.game.server, handler, options) -# create initial dialogs -import dialog + # create initial dialogs + if first: + import dialog + else: + reload(dialog) + gdata.savePassword = gdata.config.game.lastpasswordcrypted != None -gdata.savePassword = gdata.config.game.lastpasswordcrypted != None + if options.login and options.password: + gdata.config.game.lastlogin = options.login + gdata.config.game.lastpassword = options.password + gdata.config.game.lastpasswordcrypted = binascii.b2a_base64(options.password).strip() + gdata.config.game.autologin = 'yes' + gdata.savePassword = 'no' -if options.login and options.password: - gdata.config.game.lastlogin = options.login - gdata.config.game.lastpassword = options.password - gdata.config.game.lastpasswordcrypted = binascii.b2a_base64(options.password).strip() - gdata.config.game.autologin = 'yes' - gdata.savePassword = 'no' + if not first: + gdata.config.game.autologin = 'no' -loginDlg = dialog.LoginDlg(gdata.app) -updateDlg = dialog.UpdateDlg(gdata.app) -# event loop -update() + loginDlg = dialog.LoginDlg(gdata.app) + updateDlg = dialog.UpdateDlg(gdata.app) -running = 1 -lastSave = time.clock() -# set counter to -1 to trigger Update dialog (see "if" below) -counter = -1 -needsRefresh = False -while running: - try: - counter += 1 - if counter == 0: - # display initial dialog in the very first cycle - updateDlg.display(caller = loginDlg, options = options) - # process as many events as possible before updating - evt = pygame.event.wait() - evts = pygame.event.get() - evts.insert(0, evt) + # event loop + update() - forceKeepAlive = False - saveDB = False + lastSave = time.clock() + # set counter to -1 to trigger Update dialog (see "if" below) + counter = -1 + needsRefresh = False + session = 1 + first = False + while running and session: + try: + counter += 1 + if counter == 0: + # display initial dialog in the very first cycle + updateDlg.display(caller = loginDlg, options = options) + # process as many events as possible before updating + evt = pygame.event.wait() + evts = pygame.event.get() + evts.insert(0, evt) - for evt in evts: - if evt.type == QUIT: - running = 0 - break - if evt.type == ACTIVEEVENT: - if evt.gain == 1 and evt.state == 6: - # pygame desktop window focus event - needsRefresh = True - if evt.type == KEYUP and evt.key == K_F12: - running = 0 - break - if evt.type == KEYUP and evt.key == K_F9: - forceKeepAlive = True - evt = app.processEvent(evt) + forceKeepAlive = False + saveDB = False + + for evt in evts: + if evt.type == QUIT: + running = 0 + break + if evt.type == (USEREVENT + 1): + if getattr(evt, 'action', None) == 'localExit': + session = 0 + break + if evt.type == ACTIVEEVENT: + if evt.gain == 1 and evt.state == 6: + # pygame desktop window focus event + needsRefresh = True + if evt.type == KEYUP and evt.key == K_F12: + running = 0 + break + if evt.type == KEYUP and evt.key == K_F9: + forceKeepAlive = True + evt = app.processEvent(evt) - if app.needsUpdate() or isHWSurface or needsRefresh: - needsRefresh = False - update() - # keep alive connection - client.keepAlive(forceKeepAlive) + if app.needsUpdate() or isHWSurface or needsRefresh: + needsRefresh = False + update() + # keep alive connection + client.keepAlive(forceKeepAlive) - # save DB every 4 hours in case of a computer crash - # using "counter" to limit calls to time.clock() to approximately every 10-15 minutes - if counter > 5000: - # set this to zero so we don't display Update dialog - counter = 0 - if time.clock() - lastSave > 14400: - saveDB = True - if saveDB: - client.saveDB() - lastSave = time.clock(); + # save DB every 4 hours in case of a computer crash + # using "counter" to limit calls to time.clock() to approximately every 10-15 minutes + if counter > 5000: + # set this to zero so we don't display Update dialog + counter = 0 + if time.clock() - lastSave > 14400: + saveDB = True + if saveDB: + client.saveDB() + lastSave = time.clock(); - except IClientException, e: - client.reinitialize() - gdata.app.setStatus(e.args[0]) - loginDlg.display(message = e.args[0]) - except Exception, e: - log.warning('OSCI', 'Exception in event loop') - if not isinstance(e, SystemExit) and not isinstance(e, KeyboardInterrupt): - log.debug("Processing exception") - # handle exception - import traceback, StringIO - fh = StringIO.StringIO() - exctype, value, tb = sys.exc_info() - funcs = [entry[2] for entry in traceback.extract_tb(tb)] - faultID = "%04d-%06d-%03d" % ( - ige.version.version["svnRevision"], - hash("/".join(funcs)) % 1000000, - traceback.extract_tb(tb)[-1][1] % 1000, - ) - del tb - # high level info - print >>fh, "Exception ID:", faultID - print >>fh - print >>fh, "%s: %s" % (exctype, value) - print >>fh - print >>fh, "--- EXCEPTION DATA ---" - # dump exception - traceback.print_exc(file = fh) - excDlg = dialog.ExceptionDlg(app) - excDlg.display(faultID, fh.getvalue()) - del excDlg # reference to the dialog holds app's intance - fh.close() - del fh - else: - break + except IClientException, e: + client.reinitialize() + gdata.app.setStatus(e.args[0]) + loginDlg.display(message = e.args[0]) + except Exception, e: + log.warning('OSCI', 'Exception in event loop') + if not isinstance(e, SystemExit) and not isinstance(e, KeyboardInterrupt): + log.debug("Processing exception") + # handle exception + import traceback, StringIO + fh = StringIO.StringIO() + exctype, value, tb = sys.exc_info() + funcs = [entry[2] for entry in traceback.extract_tb(tb)] + faultID = "%04d-%06d-%03d" % ( + ige.version.version["svnRevision"], + hash("/".join(funcs)) % 1000000, + traceback.extract_tb(tb)[-1][1] % 1000, + ) + del tb + # high level info + print >>fh, "Exception ID:", faultID + print >>fh + print >>fh, "%s: %s" % (exctype, value) + print >>fh + print >>fh, "--- EXCEPTION DATA ---" + # dump exception + traceback.print_exc(file = fh) + excDlg = dialog.ExceptionDlg(app) + excDlg.display(faultID, fh.getvalue()) + del excDlg # reference to the dialog holds app's intance + fh.close() + del fh + else: + break -# write configuration -log.debug("Saving configuration.") -# Save highlights -hl = "" -for playerID in gdata.playersHighlightColors.keys(): - color = gdata.playersHighlightColors[playerID] - r = hex(color[0]) - g = hex(color[1]) - b = hex(color[2]) - hl = "%s %s:%s,%s,%s" % (hl,playerID,r,g,b) -gdata.config.defaults.colors = hl -# Save objects -of = "" -for keyNum in gdata.objectFocus.keys(): - objid = gdata.objectFocus[keyNum] - of = "%s %s:%s" % (of,keyNum,objid) -gdata.config.defaults.objectkeys = of -# -if gdata.savePassword == False: - gdata.config.game.lastpasswordcrypted = None -gdata.config.save() + # write configuration + log.debug("Saving configuration.") + # Save highlights + hl = "" + for playerID in gdata.playersHighlightColors.keys(): + color = gdata.playersHighlightColors[playerID] + r = hex(color[0]) + g = hex(color[1]) + b = hex(color[2]) + hl = "%s %s:%s,%s,%s" % (hl,playerID,r,g,b) + gdata.config.defaults.colors = hl + # Save objects + of = "" + for keyNum in gdata.objectFocus.keys(): + objid = gdata.objectFocus[keyNum] + of = "%s %s:%s" % (of,keyNum,objid) + gdata.config.defaults.objectkeys = of + # + if gdata.savePassword == False: + gdata.config.game.lastpasswordcrypted = None + gdata.config.save() -# logout -client.logout() + # logout + client.logout() +client.finishGalaxer() +galaxerProc.join() +client.finishServer() +serverProc.join() log.debug("Shut down") Modified: branches/singleplayer/client-pygame/lib/osci/messages.py =================================================================== --- branches/singleplayer/client-pygame/lib/osci/messages.py 2012-06-09 06:21:25 UTC (rev 328) +++ branches/singleplayer/client-pygame/lib/osci/messages.py 2012-06-09 08:27:28 UTC (rev 329) @@ -186,6 +186,7 @@ addMsg(MSG_GNC_GALAXY_RESTARTED, N_("Galaxy %(2)s knows its winner - Imperator %(1)s\n\nToday the galaxy %(2)s has been united and the peace has been restored. Majority of commanders voted for Imperator %(1)s as their supreme leader. Congratulations, Imperator, you were brave and wise!\n\nMessage from imperator:\n%(3)s"), (unicode, unicode, impMsg), severity = MAJ) addMsg(MSG_GNC_GALAXY_GENERATOR, N_("Galaxy %(1)s generation is completed. Galaxy specifications:\n\n%(2)s"), (unicode, votes2Txt,), severity = INFO) addMsg(MSG_GNC_GALAXY_AUTO_RESTARTED, N_("Galaxy %(1)s has ended\n\nToday the galaxy %(1)s has been automatically ended.\n\nReason:\n%(2)s"), (unicode, impMsg), severity = MAJ) +addMsg(MSG_GNC_GALAXY_RESIGNED_LOCAL, N_("Galaxy %(1)s has ended\n\nOnce again the galaxy %(1)s fell into the chaos, leaving no traces in the history of the universe."), (unicode,), severity = MAJ) # i18n del N_ Modified: branches/singleplayer/client-pygame/lib/pygameui/Application.py =================================================================== --- branches/singleplayer/client-pygame/lib/pygameui/Application.py 2012-06-09 06:21:25 UTC (rev 328) +++ branches/singleplayer/client-pygame/lib/pygameui/Application.py 2012-06-09 08:27:28 UTC (rev 329) @@ -320,6 +320,10 @@ def needsUpdate(self): return len(self.redrawWidgets) > 0 + def localExit(self): + evt = pygame.event.Event(USEREVENT, {'action':'localExit'}) + pygame.event.post(evt) + def exit(self): pygame.event.post(pygame.event.Event(QUIT)) Modified: branches/singleplayer/client-pygame/lib/pygameui/Entry.py =================================================================== --- branches/singleplayer/client-pygame/lib/pygameui/Entry.py 2012-06-09 06:21:25 UTC (rev 328) +++ branches/singleplayer/client-pygame/lib/pygameui/Entry.py 2012-06-09 08:27:28 UTC (rev 329) @@ -100,7 +100,7 @@ self.cursorPos = len(self.text) def onFocusLost(self): - Widget.onFocusLost(self) +# Widget.onFocusLost(self) self.processAction(self.action) registerWidget(Entry, 'entry') Modified: branches/singleplayer/client-pygame/osc.py =================================================================== --- branches/singleplayer/client-pygame/osc.py 2012-06-09 06:21:25 UTC (rev 328) +++ branches/singleplayer/client-pygame/osc.py 2012-06-09 08:27:28 UTC (rev 329) @@ -23,20 +23,27 @@ # tweak PYTHONPATH import sys import os + sys.path.insert(0, "lib") +sys.path.insert(0, "../server") for item in ("libsrvr", "../server/lib"): if os.path.exists(item): sys.path.insert(0, item) break +from run import runServer +from run_ai import runAIs +from run_galaxer import runGalaxer + #configure gc #import gc #gc.set_deb... [truncated message content] |
From: <da...@us...> - 2012-06-09 06:21:31
|
Revision: 328 http://ospace.svn.sourceforge.net/ospace/?rev=328&view=rev Author: dahaic Date: 2012-06-09 06:21:25 +0000 (Sat, 09 Jun 2012) Log Message: ----------- Creation of singleplayer feature branch Added Paths: ----------- branches/singleplayer/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qa...@us...> - 2012-02-07 14:02:04
|
Revision: 327 http://ospace.svn.sourceforge.net/ospace/?rev=327&view=rev Author: qark Date: 2012-02-07 14:01:52 +0000 (Tue, 07 Feb 2012) Log Message: ----------- - Client now handles better situation when server is down. [Qark] - Server now supports metaserver accounts with local fallback. [Qark] Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/client-pygame/lib/osci/client.py branches/ospace_0.5/client-pygame/lib/osci/dialog/LoginDlg.py branches/ospace_0.5/server/lib/ige/Authentication.py branches/ospace_0.5/server/lib/ige/ClientMngr.py branches/ospace_0.5/server/run.py Added Paths: ----------- branches/ospace_0.5/server/lib/ige/MetaServer.py Property Changed: ---------------- branches/ospace_0.5/ Property changes on: branches/ospace_0.5 ___________________________________________________________________ Modified: svn:ignore - *.bat *.lnk .project .pydevproject .settings OuterSpace-* dist_src dist_win32 installer-cache setup.iss installer.aip + *.bat *.lnk .project .pydevproject .settings OuterSpace-* dist_src dist_win32 installer-cache setup.iss installer.aip test Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2012-01-02 10:39:45 UTC (rev 326) +++ branches/ospace_0.5/ChangeLog.txt 2012-02-07 14:01:52 UTC (rev 327) @@ -6,6 +6,10 @@ - $Author$ - $Revision$ +[2012-02-07] +- Client now handles better situation when server is down. [Qark] +- Server now supports metaserver accounts with local fallback. [Qark] + [2012-01-02] - Client is now backward compatible with 0.5.68 server. [Qark] Modified: branches/ospace_0.5/client-pygame/lib/osci/client.py =================================================================== --- branches/ospace_0.5/client-pygame/lib/osci/client.py 2012-01-02 10:39:45 UTC (rev 326) +++ branches/ospace_0.5/client-pygame/lib/osci/client.py 2012-02-07 14:01:52 UTC (rev 327) @@ -50,6 +50,7 @@ def reinitialize(): global cmdProxy cmdProxy = None + initCmdProxy(options.heartbeat) def initCmdProxy(keepAliveTime): global cmdProxy, server Modified: branches/ospace_0.5/client-pygame/lib/osci/dialog/LoginDlg.py =================================================================== --- branches/ospace_0.5/client-pygame/lib/osci/dialog/LoginDlg.py 2012-01-02 10:39:45 UTC (rev 326) +++ branches/ospace_0.5/client-pygame/lib/osci/dialog/LoginDlg.py 2012-02-07 14:01:52 UTC (rev 327) @@ -27,6 +27,7 @@ from OptionsDlg import OptionsDlg import binascii from ige import log +from igeclient.IClient import IClientException class LoginDlg: @@ -41,8 +42,11 @@ def display(self, caller = None, message = None): self.caller = caller # get game names from the server - try: + try: self.gameIDs = client.cmdProxy.getRegisteredGames() + except IClientException: + # server is probably down, what to do? + self.gameIDs = {"UNDEFINED": "Not available"} except KeyError: # server does not support this call self.gameIDs = {"Alpha": "Alpha"} Modified: branches/ospace_0.5/server/lib/ige/Authentication.py =================================================================== --- branches/ospace_0.5/server/lib/ige/Authentication.py 2012-01-02 10:39:45 UTC (rev 326) +++ branches/ospace_0.5/server/lib/ige/Authentication.py 2012-02-07 14:01:52 UTC (rev 327) @@ -79,12 +79,30 @@ def verify(encodedPassword, password, challenge): """Verify password based on client encoded password and auth method""" method = getMethod(challenge) + return processUserPassword(encodedPassword, challenge) == processStoredPassword(password, challenge) + +def processUserPassword(password, challenge): + """Decode password according to auth method (if possible)""" + method = getMethod(challenge) if method == "plain": - return encodedPassword == password + return password elif method == "md5" or challenge.startswith("IGEServer@"): - return hashlib.md5(password + challenge).hexdigest() == encodedPassword + return password elif method == "sha256": - return hashlib.sha256(password + challenge).hexdigest() == encodedPassword + return password elif method == "rsa": - return rsa.decrypt(binascii.unhexlify(encodedPassword), getPrivateKey()) == password + return rsa.decrypt(binascii.unhexlify(password), getPrivateKey()) raise SecurityException("Unsupported authentication method %s" % str(method)) + +def processStoredPassword(password, challenge): + """Encode stored password for comparison with user provided password""" + method = getMethod(challenge) + if method == "plain": + return password + elif method == "md5" or challenge.startswith("IGEServer@"): + return hashlib.md5(password + challenge).hexdigest() + elif method == "sha256": + return hashlib.sha256(password + challenge).hexdigest() + elif method == "rsa": + return password + raise SecurityException("Unsupported authentication method %s" % str(method)) Modified: branches/ospace_0.5/server/lib/ige/ClientMngr.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ClientMngr.py 2012-01-02 10:39:45 UTC (rev 326) +++ branches/ospace_0.5/server/lib/ige/ClientMngr.py 2012-02-07 14:01:52 UTC (rev 327) @@ -47,9 +47,10 @@ class ClientMngr: - def __init__(self, database, authMethod, configDir): + def __init__(self, database, authMethod, configDir, metaserver = None): self.configDir = configDir self.authMethod = authMethod + self.metaserver = metaserver if not self.authMethod: self.authMethod = Authentication.defaultMethod self._filename = os.path.join(self.configDir, 'accounts') @@ -172,13 +173,29 @@ raise SecurityException("Account blocked") log.debug(sid, 'login', repr(login), 'hostid', hostID) login = str(login) - if not self.accounts.has_key(login): - raise SecurityException('Wrong login and/or password.') - - account = self.accounts[login] challenge = self.sessions[sid].challenge - if not Authentication.verify(cpasswd, account.passwd, challenge): - raise SecurityException('Wrong login and/or password.') + account = None + # use metaserver login if metaserver is defined + if self.metaserver: + result = self.metaserver.verifyPassword(login, Authentication.processUserPassword(cpasswd, challenge)) + if result: + account = Account() + account.login = login + account.nick = result["nick"] + account.email = result["email"] + log.debug("User", login, "has valid metaserver account") + #else: + # raise SecurityException("Wrong login and/or password.") + # local login + # TBD: option to disable local login completely + if not account: + log.debug("Trying local login for user", login) + if not self.accounts.has_key(login): + raise SecurityException('Wrong login and/or password.') + account = self.accounts[login] + if not Authentication.verify(cpasswd, account.passwd, challenge): + raise SecurityException('Wrong login and/or password.') + # setup session self.sessions[sid].setAttrs(account.login, account.nick, account.email) account.lastLogin = time.time() account.addHostID(hostID) Added: branches/ospace_0.5/server/lib/ige/MetaServer.py =================================================================== --- branches/ospace_0.5/server/lib/ige/MetaServer.py (rev 0) +++ branches/ospace_0.5/server/lib/ige/MetaServer.py 2012-02-07 14:01:52 UTC (rev 327) @@ -0,0 +1,36 @@ +# +# Copyright 2001 - 2012 Ludek Smid [http://www.ospace.net/] +# +# This file is part of Outer Space. +# +# Outer Space is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# Outer Space is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with IGE - Outer Space; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +import xmlrpclib +from ige import log + +class WordpressMetaServer(object): + """Instance of this class provides metaserver RPC interface""" + + def __init__(self, url): + self.rpc = xmlrpclib.ServerProxy(url) + + def verifyPassword(self, login, password): + """Called by Authentication module, returns 0 if password is valid""" + try: + return self.rpc.ospace.verify_user(login, password) + except xmlrpclib.Fault, f: + if f.faultString == "Bad login/pass combination.": + return False + log.warning("Cannot complete Wordpress XML-RPC call") Property changes on: branches/ospace_0.5/server/lib/ige/MetaServer.py ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: branches/ospace_0.5/server/run.py =================================================================== --- branches/ospace_0.5/server/run.py 2012-01-02 10:39:45 UTC (rev 326) +++ branches/ospace_0.5/server/run.py 2012-02-07 14:01:52 UTC (rev 327) @@ -201,10 +201,16 @@ # initialize game log.message('Initializing game \'%s\'...' % gameName) +metaserver = None +if config.wordpressmetaserver.url: + from ige.MetaServer import WordpressMetaServer + metaserver = WordpressMetaServer(config.wordpressmetaserver.url) + assert config.server.authmethod in ("plain", "rsa"), "Only plain and rsa authmethod supported for metaservers" + log.debug("Initializing issue manager") issueMngr = IssueMngr() log.debug("Initializing client manager") -clientMngr = ClientMngr(clientDB, config.server.authmethod, options.configDir) +clientMngr = ClientMngr(clientDB, config.server.authmethod, options.configDir, metaserver) log.debug("Initializing message manager") msgMngr = MsgMngr(msgDB) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qa...@us...> - 2012-01-02 10:39:52
|
Revision: 326 http://ospace.svn.sourceforge.net/ospace/?rev=326&view=rev Author: qark Date: 2012-01-02 10:39:45 +0000 (Mon, 02 Jan 2012) Log Message: ----------- - Client is now backward compatible with 0.5.68 server. [Qark] Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/client-pygame/lib/osci/dialog/LoginDlg.py Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2011-12-30 20:19:32 UTC (rev 325) +++ branches/ospace_0.5/ChangeLog.txt 2012-01-02 10:39:45 UTC (rev 326) @@ -6,6 +6,9 @@ - $Author$ - $Revision$ +[2012-01-02] +- Client is now backward compatible with 0.5.68 server. [Qark] + [2011-12-30] - ospace-server.py supports multiple Universes now. [Qark] - Client now supports Universe selection. [Qark] Modified: branches/ospace_0.5/client-pygame/lib/osci/dialog/LoginDlg.py =================================================================== --- branches/ospace_0.5/client-pygame/lib/osci/dialog/LoginDlg.py 2011-12-30 20:19:32 UTC (rev 325) +++ branches/ospace_0.5/client-pygame/lib/osci/dialog/LoginDlg.py 2012-01-02 10:39:45 UTC (rev 326) @@ -40,8 +40,12 @@ def display(self, caller = None, message = None): self.caller = caller - # TODO: get real names from the server - self.gameIDs = client.cmdProxy.getRegisteredGames() + # get game names from the server + try: + self.gameIDs = client.cmdProxy.getRegisteredGames() + except KeyError: + # server does not support this call + self.gameIDs = {"Alpha": "Alpha"} # show / hide new account button self.win.vCreate.visible = gdata.config.game.accountcreated == None # fill in default values This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qa...@us...> - 2011-12-30 20:19:39
|
Revision: 325 http://ospace.svn.sourceforge.net/ospace/?rev=325&view=rev Author: qark Date: 2011-12-30 20:19:32 +0000 (Fri, 30 Dec 2011) Log Message: ----------- - ospace-server.py supports multiple Universes now. [Qark] - Client now supports Universe selection. [Qark] - Client save filename now contains universe ID to prevent conflicts. [Qark] - Fixed bug where IUniverse and other objects had oid set to OID_NONE. [Qark] Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/client-pygame/lib/osci/client.py branches/ospace_0.5/client-pygame/lib/osci/dialog/LoginDlg.py branches/ospace_0.5/server/lib/ige/GameMngr.py branches/ospace_0.5/server/lib/ige/GameServer.py branches/ospace_0.5/server/lib/ige/RPCServer.py branches/ospace_0.5/server/lib/ige/SQLiteDatabase.py branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py branches/ospace_0.5/server/lib/igeclient/IClient.py branches/ospace_0.5/server/lib/igeclient/IClientDB.py Property Changed: ---------------- branches/ospace_0.5/server/website/ Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2011-12-28 19:02:47 UTC (rev 324) +++ branches/ospace_0.5/ChangeLog.txt 2011-12-30 20:19:32 UTC (rev 325) @@ -6,6 +6,12 @@ - $Author$ - $Revision$ +[2011-12-30] +- ospace-server.py supports multiple Universes now. [Qark] +- Client now supports Universe selection. [Qark] +- Client save filename now contains universe ID to prevent conflicts. [Qark] +- Fixed bug where IUniverse and other objects had oid set to OID_NONE. [Qark] + [2011-12-28] - Initial version of support for multiple universes per game server. [Qark] Modified: branches/ospace_0.5/client-pygame/lib/osci/client.py =================================================================== --- branches/ospace_0.5/client-pygame/lib/osci/client.py 2011-12-28 19:02:47 UTC (rev 324) +++ branches/ospace_0.5/client-pygame/lib/osci/client.py 2011-12-30 20:19:32 UTC (rev 325) @@ -177,7 +177,7 @@ # get real turn result = cmdProxy.getIntroInfo(OID_UNIVERSE) if not db: - db = IClientDB.IClientDB(result.cid, result.turn, options.configDir) + db = IClientDB.IClientDB(result.cid, result.turn, options.configDir, cmdProxy.gameID) if clearDB: db.clear() db.turn = result.turn Modified: branches/ospace_0.5/client-pygame/lib/osci/dialog/LoginDlg.py =================================================================== --- branches/ospace_0.5/client-pygame/lib/osci/dialog/LoginDlg.py 2011-12-28 19:02:47 UTC (rev 324) +++ branches/ospace_0.5/client-pygame/lib/osci/dialog/LoginDlg.py 2011-12-30 20:19:32 UTC (rev 325) @@ -1,5 +1,5 @@ # -# Copyright 2001 - 2010 Ludek Smid [http://www.ospace.net/] +# Copyright 2001 - 2012 Ludek Smid [http://www.ospace.net/] # # This file is part of Outer Space. # @@ -40,7 +40,11 @@ def display(self, caller = None, message = None): self.caller = caller + # TODO: get real names from the server + self.gameIDs = client.cmdProxy.getRegisteredGames() + # show / hide new account button self.win.vCreate.visible = gdata.config.game.accountcreated == None + # fill in default values if gdata.config.game.lastlogin != None: self.win.vLogin.text = gdata.config.game.lastlogin if gdata.config.game.lastpassword: @@ -49,6 +53,13 @@ self.win.vPassword.text = binascii.a2b_base64(gdata.config.game.lastpasswordcrypted) if not gdata.config.game.lastgameid: gdata.config.game.lastgameid = 'Alpha' + if gdata.config.game.lastgameid not in self.gameIDs: + # use first gameid returned by server + gdata.config.game.lastgameid = sorted(self.gameIDs.keys())[0] + self.win.vUniverse.text = self.gameIDs[gdata.config.game.lastgameid] + self.win.vUniverse.data = gdata.config.game.lastgameid + # disable Universe selection if there's just one universe on the server + self.win.vUniverse.enabled = len(self.gameIDs) > 1 self.win.vMessage.text = message #if gdata.config.game.autologin != 'yes': # enable this to disable auto-login after change in options # self.firstlogin = false @@ -65,14 +76,14 @@ self.win.vMessage.text = _('Auto-login in progress ...') login = self.win.vLogin.text password = self.win.vPassword.text - gameID = gdata.config.game.lastgameid + gameID = self.win.vUniverse.data self.doLogin(gameID,login,password) def onLogin(self, widget, action, data): self.firstlogin = False login = self.win.vLogin.text password = self.win.vPassword.text - gameID = gdata.config.game.lastgameid + gameID = self.win.vUniverse.data self.win.vMessage.text = _('Login in progress ...') # self.win.hide() self.doLogin(gameID,login,password) @@ -146,43 +157,74 @@ gdata.config.game.lastpasswordcrypted = binascii.b2a_base64(self.win.vPassword.text).strip() OptionsDlg(gdata.app).display(self) + def onUniverse(self, widget, action, data): + # create menu + items = list() + index = 0 + for gameID in sorted(self.gameIDs.keys()): + item = ui.Item(self.gameIDs[gameID], data = gameID, action = "onUniverseSelected") + items.append(item) + index += 1 + self.universeMenu.items = items + # show + self.universeMenu.show((self.win.rect.x + 11 * 20 + 2, self.win.rect.y + 20 + 2)) + + def onUniverseSelected(self, widget, action, data): + self.win.vUniverse.text = self.gameIDs[data] + self.win.vUniverse.data = data + def createUI(self): w, h = gdata.scrnSize self.win = ui.Window(self.app, modal = 1, movable = 0, title = _('Outer Space Login'), - rect = ui.Rect((w - 424) / 2, (h - 124) / 2, 424, 124), + rect = ui.Rect((w - 424) / 2, (h - 144) / 2, 424, 144), layoutManager = ui.SimpleGridLM(), tabChange = True, ) self.win.subscribeAction('*', self) ui.Label(self.win, - text = _('Login'), + text = _('Universe'), align = ui.ALIGN_E, layout = (5, 0, 6, 1) ) + ui.Button(self.win, id = 'vUniverse', + align = ui.ALIGN_W, + layout = (11, 0, 10, 1), + action = "onUniverse", + ) + ui.Label(self.win, + text = _('Login'), + align = ui.ALIGN_E, + layout = (5, 1, 6, 1) + ) ui.Entry(self.win, id = 'vLogin', align = ui.ALIGN_W, - layout = (11, 0, 10, 1), + layout = (11, 1, 10, 1), orderNo = 1 ) ui.Label(self.win, text = _('Password'), align = ui.ALIGN_E, - layout = (5, 1, 6, 1), + layout = (5, 2, 6, 1), ) ui.Entry(self.win, id = 'vPassword', align = ui.ALIGN_W, showChar = '*', - layout = (11, 1, 10, 1), + layout = (11, 2, 10, 1), orderNo = 2 ) - ui.Button(self.win, layout = (11, 2, 10, 1), text = _("Options"), action = "onOptions", id = "vOptions") - ui.Button(self.win, layout = (11, 3, 10, 1), text = _("New account"), + ui.Button(self.win, layout = (11, 3, 10, 1), text = _("Options"), action = "onOptions", id = "vOptions") + ui.Button(self.win, layout = (11, 4, 10, 1), text = _("New account"), action = "onCreateAccount", id = "vCreate") - ui.Title(self.win, layout = (0, 4, 11, 1), id = 'vMessage', align = ui.ALIGN_W) - ui.TitleButton(self.win, layout = (11, 4, 5, 1), text = _('Exit'), action = 'onCancel') - loginBtn = ui.TitleButton(self.win, layout = (16, 4, 5, 1), text = _('Login'), action = 'onLogin') + ui.Title(self.win, layout = (0, 5, 11, 1), id = 'vMessage', align = ui.ALIGN_W) + ui.TitleButton(self.win, layout = (11, 5, 5, 1), text = _('Exit'), action = 'onCancel') + loginBtn = ui.TitleButton(self.win, layout = (16, 5, 5, 1), text = _('Login'), action = 'onLogin') ui.Label(self.win, layout = (0, 0, 5, 4), icons = ((res.loginLogoImg, ui.ALIGN_W),)) self.win.acceptButton = loginBtn + # Universe selection + self.universeMenu = ui.Menu(self.app, title = _("Universes"), + width = 10, + ) + self.universeMenu.subscribeAction("*", self) Modified: branches/ospace_0.5/server/lib/ige/GameMngr.py =================================================================== --- branches/ospace_0.5/server/lib/ige/GameMngr.py 2011-12-28 19:02:47 UTC (rev 324) +++ branches/ospace_0.5/server/lib/ige/GameMngr.py 2011-12-30 20:19:32 UTC (rev 325) @@ -34,10 +34,11 @@ class GameMngr: - def __init__(self, gameID, config, clientMngr, msgMngr, database, configDir): + def __init__(self, gameID, config, clientMngr, msgMngr, database, configDir, gameName = None): log.debug("Runtime mode", ige.igeRuntimeMode) self.status = GS_INIT self.gameID = gameID + self.gameName = gameName or gameID self.clientMngr = clientMngr self.msgMngr = msgMngr self.cmdPool = {} Modified: branches/ospace_0.5/server/lib/ige/GameServer.py =================================================================== --- branches/ospace_0.5/server/lib/ige/GameServer.py 2011-12-28 19:02:47 UTC (rev 324) +++ branches/ospace_0.5/server/lib/ige/GameServer.py 2011-12-30 20:19:32 UTC (rev 325) @@ -38,8 +38,7 @@ def __init__(self, configuration): self.loadConfigFile(configuration) # inititalization - self.issueMngr = IssueMngr() - self.initializeClientMngr() + self.initializeSharedMngrs() # initialize games self.games = list() for section in self.config.sections(): @@ -68,7 +67,10 @@ assert self.config.server.datadir, "server.datadir MUST be defined" assert self.config.server.dbdir, "server.dbdir MUST be defined" - def initializeClientMngr(self): + def initializeSharedMngrs(self): + """Initialize managers that are shared across all game instances""" + self.issueMngr = IssueMngr() + # client manager db = DatabaseString(self.config.server.dbdir, "accounts", cache = 100) self.clientMngr = ClientMngr(db, self.config.server.authmethod, self.config.server.datadir) @@ -82,7 +84,7 @@ gameDB = Database(self.config.server.dbdir, "%s_game" % gameID, cache = 15000) msgDB = DatabaseString(self.config.server.dbdir, "%s_msgs" % gameID, cache = 1000) msgMngr = MsgMngr(msgDB) - gameMngr = GameMngr(gameID, config, self.clientMngr, msgMngr, gameDB, self.config.server.datadir) + gameMngr = GameMngr(gameID, config, self.clientMngr, msgMngr, gameDB, self.config.server.datadir, config.name) # reset game if Universe does not exist if not gameDB.has_key(OID_UNIVERSE): log.message('Resetting game \'%s\'...' % gameID) @@ -99,4 +101,4 @@ @rpc def getConfiguration(self): """Return configuration of the server""" - return \ No newline at end of file + return \ No newline at end of file Modified: branches/ospace_0.5/server/lib/ige/RPCServer.py =================================================================== --- branches/ospace_0.5/server/lib/ige/RPCServer.py 2011-12-28 19:02:47 UTC (rev 324) +++ branches/ospace_0.5/server/lib/ige/RPCServer.py 2011-12-30 20:19:32 UTC (rev 325) @@ -28,6 +28,7 @@ callMap = {} objMap = {} +registeredGames = {} running = 0 @@ -47,6 +48,9 @@ result["clientURLs"] = ige.version.clientURLs return result, None +def getRegisteredGamesHandler(obj): + return registeredGames, None + ## IGE RPC medusa handler class igerpc(igerpc_handler.igerpc_handler): @@ -159,6 +163,7 @@ callMap['getVersion'] = versionHandler callMap['getToken'] = clientMngr.getToken callMap['getSessionByToken'] = clientMngr.getSessionByToken + callMap['getRegisteredGames'] = getRegisteredGamesHandler def register(game): global callMap @@ -173,7 +178,10 @@ callMap[game.gameID + '.processTurn'] = game.processTurn callMap[game.gameID + '.backup'] = game.backup callMap[game.gameID + '.commitDatabases'] = game.commitDatabases - + + global registeredGames + registeredGames[game.gameID] = game.gameName + def xmlrpcPublish(name, obj): objMap[name] = obj Modified: branches/ospace_0.5/server/lib/ige/SQLiteDatabase.py =================================================================== --- branches/ospace_0.5/server/lib/ige/SQLiteDatabase.py 2011-12-28 19:02:47 UTC (rev 324) +++ branches/ospace_0.5/server/lib/ige/SQLiteDatabase.py 2011-12-30 20:19:32 UTC (rev 325) @@ -263,6 +263,9 @@ id += 1 self.nextID = id + 1 object.oid = id + elif hasattr(object, "oid") and object.oid != id: + log.message("Object OID '%s' != forced OID '%s' - FIXING" % (object.oid, id)) + object.oid = id #@log.debug("OID =", id) if self.has_key(id): raise ige.ServerException("'%s' created twice" % id) Modified: branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py 2011-12-28 19:02:47 UTC (rev 324) +++ branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py 2011-12-30 20:19:32 UTC (rev 325) @@ -45,8 +45,8 @@ # Reguired methods # - def __init__(self, gameID, config, clientMngr, msgMngr, database, configDir): - IGEGameMngr.__init__(self, gameID, config, clientMngr, msgMngr, database, configDir) + def __init__(self, gameID, config, clientMngr, msgMngr, database, configDir, gameName = None): + IGEGameMngr.__init__(self, gameID, config, clientMngr, msgMngr, database, configDir, gameName) # register command object self.registerObject(IUniverse.IUniverse) self.registerObject(IPlayer.IPlayer) @@ -108,9 +108,9 @@ #self.cmdPool[galaxy.type].setupEnvironment(tran, galaxy) ## start time #self.cmdPool[galaxy.type].enableTime(tran, galaxy, force = 1) - ## create 'NATURE' player - #player = self.cmdPool[T_NATURE].new(T_NATURE) - #self.registerPlayer(player.login, player, OID_NATURE) + # create 'NATURE' player + player = self.cmdPool[T_NATURE].new(T_NATURE) + self.registerPlayer(player.login, player, OID_NATURE) def getTurnData(self, sid): IGEGameMngr.getTurnData(self, sid) Modified: branches/ospace_0.5/server/lib/igeclient/IClient.py =================================================================== --- branches/ospace_0.5/server/lib/igeclient/IClient.py 2011-12-28 19:02:47 UTC (rev 324) +++ branches/ospace_0.5/server/lib/igeclient/IClient.py 2011-12-30 20:19:32 UTC (rev 325) @@ -92,6 +92,9 @@ def getVersion(self): return apply(IProxy('getVersion', None, self), ()) + def getRegisteredGames(self): + return apply(IProxy('getRegisteredGames', None, self), ()) + def getToken(self): return apply(IProxy('getToken', None, self), ()) Modified: branches/ospace_0.5/server/lib/igeclient/IClientDB.py =================================================================== --- branches/ospace_0.5/server/lib/igeclient/IClientDB.py 2011-12-28 19:02:47 UTC (rev 324) +++ branches/ospace_0.5/server/lib/igeclient/IClientDB.py 2011-12-30 20:19:32 UTC (rev 325) @@ -23,8 +23,9 @@ from ige import log class IClientDB: - def __init__(self, cid, turn, dataDir = 'var'): + def __init__(self, cid, turn, dataDir = 'var', gameID = "UNDEFINED"): self.playerID = cid + self.gameID = gameID self.turn = turn self.dataDir = dataDir self.load() @@ -52,10 +53,10 @@ def load(self): try: - fh = open(os.path.join(self.dataDir, '%d.data' % self.playerID), 'rb') + fh = open(os.path.join(self.dataDir, '%s_%d.data' % (self.gameID, self.playerID)), 'rb') self.data = pickle.load(fh) fh.close() - fh = open(os.path.join(self.dataDir, '%d.timestamp' % self.playerID), 'rb') + fh = open(os.path.join(self.dataDir, '%s_%d.timestamp' % (self.gameID, self.playerID)), 'rb') self.timestamp = pickle.load(fh) fh.close() except: @@ -63,10 +64,10 @@ self.timestamp = {} def save(self): - fh = open(os.path.join(self.dataDir, '%d.data' % self.playerID), 'wb') + fh = open(os.path.join(self.dataDir, '%s_%d.data' % (self.gameID, self.playerID)), 'wb') pickle.dump(self.data, fh, 1) fh.close() - fh = open(os.path.join(self.dataDir, '%d.timestamp' % self.playerID), 'wb') + fh = open(os.path.join(self.dataDir, '%s_%d.timestamp' % (self.gameID, self.playerID)), 'wb') pickle.dump(self.timestamp, fh, 1) fh.close() Property changes on: branches/ospace_0.5/server/website ___________________________________________________________________ Modified: svn:ignore - Alpha res.txt + Alpha res.txt argo beidos ceelia This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qa...@us...> - 2011-12-28 19:02:56
|
Revision: 324 http://ospace.svn.sourceforge.net/ospace/?rev=324&view=rev Author: qark Date: 2011-12-28 19:02:47 +0000 (Wed, 28 Dec 2011) Log Message: ----------- - Initial version of support for multiple universes per game server. [Qark] Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/server/lib/ige/ClientMngr.py branches/ospace_0.5/server/lib/ige/Config.py branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py branches/ospace_0.5/server/run.py Added Paths: ----------- branches/ospace_0.5/server/lib/ige/GameServer.py branches/ospace_0.5/server/ospace-server.py Removed Paths: ------------- branches/ospace_0.5/server/ospace-server Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2011-12-05 21:53:41 UTC (rev 323) +++ branches/ospace_0.5/ChangeLog.txt 2011-12-28 19:02:47 UTC (rev 324) @@ -6,6 +6,9 @@ - $Author$ - $Revision$ +[2011-12-28] +- Initial version of support for multiple universes per game server. [Qark] + [2011-12-05] - Fixed galaxy restart issue. [Qark] - Game information now exported to json. [Qark] Modified: branches/ospace_0.5/server/lib/ige/ClientMngr.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ClientMngr.py 2011-12-05 21:53:41 UTC (rev 323) +++ branches/ospace_0.5/server/lib/ige/ClientMngr.py 2011-12-28 19:02:47 UTC (rev 324) @@ -1,5 +1,5 @@ # -# Copyright 2001 - 2006 Ludek Smid [http://www.ospace.net/] +# Copyright 2001 - 2012 Ludek Smid [http://www.ospace.net/] # # This file is part of IGE - Outer Space. # @@ -47,9 +47,9 @@ class ClientMngr: - def __init__(self, database, config, configDir): + def __init__(self, database, authMethod, configDir): self.configDir = configDir - self.authMethod = config.server.authmethod + self.authMethod = authMethod if not self.authMethod: self.authMethod = Authentication.defaultMethod self._filename = os.path.join(self.configDir, 'accounts') Modified: branches/ospace_0.5/server/lib/ige/Config.py =================================================================== --- branches/ospace_0.5/server/lib/ige/Config.py 2011-12-05 21:53:41 UTC (rev 323) +++ branches/ospace_0.5/server/lib/ige/Config.py 2011-12-28 19:02:47 UTC (rev 324) @@ -32,10 +32,13 @@ existing section an instance of Section class is returned. """ - def __init__(self, file): - self.__dict__["_config"] = ConfigParser() + def __init__(self, file, defaults = dict()): + self.__dict__["_config"] = ConfigParser(defaults) self._config.read(file) + def __getitem__(self, name): + return self.__getattr__(name) + def __getattr__(self, name): if not self._config.has_section(name): self._config.add_section(name) @@ -48,6 +51,9 @@ else: raise AttributeError("Cannot assign value to config section") + def sections(self): + return self._config.sections() + def save(self, file): fh = open(file, 'w') self._config.write(fh) Added: branches/ospace_0.5/server/lib/ige/GameServer.py =================================================================== --- branches/ospace_0.5/server/lib/ige/GameServer.py (rev 0) +++ branches/ospace_0.5/server/lib/ige/GameServer.py 2011-12-28 19:02:47 UTC (rev 324) @@ -0,0 +1,102 @@ +# +# Copyright 2001 - 2012 Ludek Smid [http://www.ospace.net/] +# +# This file is part of Outer Space. +# +# Outer Space is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# Outer Space is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with IGE - Outer Space; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +import os + +from ige import log +from ige.ClientMngr import ClientMngr +from ige.Config import Config +from ige.Const import OID_UNIVERSE +from ige.ospace.GameMngr import GameMngr +from ige.IssueMngr import IssueMngr +from ige.MsgMngr import MsgMngr +from ige.SQLiteDatabase import Database, DatabaseString + +def rpc(f): + return f + +class GameServer(object): + """GameServer object manages one or more GameMngr object representing + individual games""" + + def __init__(self, configuration): + self.loadConfigFile(configuration) + # inititalization + self.issueMngr = IssueMngr() + self.initializeClientMngr() + # initialize games + self.games = list() + for section in self.config.sections(): + if not section.startswith("game"): + continue + config = self.config[section] + log.message("INITIALIZING GAME", config.gameid) + self.initializeGame(config) + + def shutdown(self): + """Shutdown whole game server""" + for game in self.games: + game.shutdown() + del self.games + self.clientMngr.shutdown() + del self.clientMngr + self.issueMngr.shutdown() + del self.issueMngr + + def loadConfigFile(self, configuration): + defaults = dict( + cwd = os.path.abspath(os.getcwd()), + ) + self.config = Config(configuration, defaults) + # make sure we have required keys defined + assert self.config.server.datadir, "server.datadir MUST be defined" + assert self.config.server.dbdir, "server.dbdir MUST be defined" + + def initializeClientMngr(self): + db = DatabaseString(self.config.server.dbdir, "accounts", cache = 100) + self.clientMngr = ClientMngr(db, self.config.server.authmethod, self.config.server.datadir) + + def initializeGame(self, config): + """Initialize game according to configuration file fragment""" + gameID = config.gameid + # make sure we have required keys defined + assert config.galaxytype, "%s.galaxytype MUST be defined" % gameID + assert config.name, "%s.name MUST be defined" % gameID + # initialize database and objects + gameDB = Database(self.config.server.dbdir, "%s_game" % gameID, cache = 15000) + msgDB = DatabaseString(self.config.server.dbdir, "%s_msgs" % gameID, cache = 1000) + msgMngr = MsgMngr(msgDB) + gameMngr = GameMngr(gameID, config, self.clientMngr, msgMngr, gameDB, self.config.server.datadir) + # reset game if Universe does not exist + if not gameDB.has_key(OID_UNIVERSE): + log.message('Resetting game \'%s\'...' % gameID) + gameMngr.reset() + # normal operations + gameMngr.init() + if self.config.server.upgradegames: + gameMngr.upgrade() + msgMngr.upgrade() + gameMngr.start() + # keep reference to this game + self.games.append(gameMngr) + + @rpc + def getConfiguration(self): + """Return configuration of the server""" + return \ No newline at end of file Property changes on: branches/ospace_0.5/server/lib/ige/GameServer.py ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py 2011-12-05 21:53:41 UTC (rev 323) +++ branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py 2011-12-28 19:02:47 UTC (rev 324) @@ -96,21 +96,21 @@ return obj def createUniverse(self): - obj = self.db[OID_UNIVERSE] - cmdObj = self.cmdPool[obj.type] + universe = self.db[OID_UNIVERSE] tran = Transaction(self, OID_ADMIN) - #! TODO this is temporary - # create sector index (needed by loadFromXML) - galaxy = self.db[cmdObj.createGalaxy(tran, obj)] - #self.cmdPool[galaxy.type].loadFromXML(tran, galaxy, 'galaxy-Argo42P.xml', 'Circle42P', 100, 100, 'Argo') - self.cmdPool[galaxy.type].loadFromXML(tran, galaxy, 'galaxy-Circle4P.xml', 'Circle4P', 100, 100, 'Galaxy Test') - # setup environment - self.cmdPool[galaxy.type].setupEnvironment(tran, galaxy) - # start time - self.cmdPool[galaxy.type].enableTime(tran, galaxy, force = 1) - # create 'NATURE' player - player = self.cmdPool[T_NATURE].new(T_NATURE) - self.registerPlayer(player.login, player, OID_NATURE) + self.cmdPool[universe.type].createNewGalaxy(tran, universe, 0, 0, self.config.name) + ##! TODO this is temporary + ## create sector index (needed by loadFromXML) + #galaxy = self.db[cmdObj.createGalaxy(tran, obj)] + ##self.cmdPool[galaxy.type].loadFromXML(tran, galaxy, 'galaxy-Argo42P.xml', 'Circle42P', 100, 100, 'Argo') + #self.cmdPool[galaxy.type].loadFromXML(tran, galaxy, 'galaxy-Circle4P.xml', 'Circle4P', 100, 100, 'Galaxy Test') + ## setup environment + #self.cmdPool[galaxy.type].setupEnvironment(tran, galaxy) + ## start time + #self.cmdPool[galaxy.type].enableTime(tran, galaxy, force = 1) + ## create 'NATURE' player + #player = self.cmdPool[T_NATURE].new(T_NATURE) + #self.registerPlayer(player.login, player, OID_NATURE) def getTurnData(self, sid): IGEGameMngr.getTurnData(self, sid) Modified: branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py 2011-12-05 21:53:41 UTC (rev 323) +++ branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py 2011-12-28 19:02:47 UTC (rev 324) @@ -550,17 +550,24 @@ def createNewGalaxy(self, tran, obj, x, y, galaxyName): - log.message("Adding new galaxy '%s' to (%d, %d)" % (galaxyName, x, y)) + galaxyType = tran.gameMngr.config.galaxytype + if type(galaxyType) != str: + # old configuration file + log.debug("OLD configuration file detected, using server.newgalaxytype!") + galaxyType = tran.gameMngr.config.server.newgalaxytype + galaxyName = "Legacy Galaxy" + assert galaxyType, "galaxytype must be defined in configuration file" + print galaxyName + log.message("Adding new galaxy '%s' with type '%s' to (%d, %d)" % (galaxyName, galaxyType, x, y)) fh, galaxyFileName = tempfile.mkstemp(text = True) log.debug("Generating new galaxy to temporary file", galaxyFileName) - strGalaxyID = tran.gameMngr.config.server.newgalaxytype - GenerateGalaxy(strGalaxyID, os.fdopen(fh, "w+b")) + GenerateGalaxy(galaxyType, os.fdopen(fh, "w+b")) log.debug("Creating new galaxy") newGalaxyID = self.createGalaxy(tran, obj) log.debug("Created new galaxy", newGalaxyID) newGalaxy = tran.db[newGalaxyID] log.debug("Loading new ", newGalaxyID) - self.cmd(newGalaxy).loadFromXML(tran, newGalaxy, galaxyFileName, strGalaxyID, x, y, galaxyName) + self.cmd(newGalaxy).loadFromXML(tran, newGalaxy, galaxyFileName, galaxyType, x, y, galaxyName) log.debug("Setup Enviroment", newGalaxyID) self.cmd(newGalaxy).setupEnvironment(tran, newGalaxy) log.debug("Sending Announcement Message", newGalaxyID) Deleted: branches/ospace_0.5/server/ospace-server =================================================================== --- branches/ospace_0.5/server/ospace-server 2011-12-05 21:53:41 UTC (rev 323) +++ branches/ospace_0.5/server/ospace-server 2011-12-28 19:02:47 UTC (rev 324) @@ -1,168 +0,0 @@ -#!/usr/bin/env python2.4 -# -# Copyright 2001 - 2006 Ludek Smid [http://www.ospace.net/] -# -# This file is part of IGE - Outer Space. -# -# IGE - Outer Space is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# IGE - Outer Space is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with IGE - Outer Space; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# - -import sys - -# setup system path -sys.path.insert(0,"lib") - -import os, atexit -import getopt - -# logger -from ige import log -log.setMessageLog('var/logs/messages.log') -log.setErrorLog('var/logs/errors.log') - -# options -# parse arguments -log.message('Parsing arguments...') -options = ('reset', 'upgrade', 'devel', 'restore') - -opts, args = getopt.getopt(sys.argv[1:], '', options) - -optReset = 0 -optUpgrade = 0 -optDevel = 0 -optRestore = 0 - -for opt, arg in opts: - if opt == '--reset': - optReset = 1 - elif opt == '--upgrade': - optUpgrade = 1 - elif opt == '--devel': - optDevel = 1 - elif opt == '--restore': - optRestore = 1 - -# record my pid - -# pid -pidFd = os.open("var/server.pid", os.O_CREAT | os.O_EXCL | os.O_WRONLY) -os.write(pidFd, str(os.getpid())) -# TODO: check if server.pid points to the running process - -game = None -msgMngr = None -clientMngr = None -issueMngr = None - -# define and register exit function -def cleanup(): -# shut down game - try: - if game: - log.message('Shutting down game...') - game.shutdown() - - if msgMngr: - log.message('Shutting down message manager...') - msgMngr.shutdown() - - if clientMngr: - log.message('Shutting down client manager...') - clientMngr.shutdown() - - if issueMngr: - log.message('Shutting down issue manager...') - issueMngr.shutdown() - except: - log.exception("Shutdown of the server failed") - - log.message('Shutted down') - log.message("Cleaning up...") - # delete my pid - os.close(pidFd) - os.remove("var/server.pid") - -atexit.register(cleanup) - -# startup game -log.debug('Importing IGE modules...') - -import ige.RPCServer as server -import ige -from ige.ClientMngr import ClientMngr -from ige.MsgMngr import MsgMngr -from ige.IssueMngr import IssueMngr -from ige.ospace.GameMngr import GameMngr - -# set runtime mode -ige.setRuntimeMode(not optDevel) - -gameName = 'Alpha' - -# open database -from ige.MetakitDatabase import MetakitDatabase, MetakitDatabaseString - -log.debug("Creating databases...") -gameDB = MetakitDatabase("var/db_data", "game_%s" % gameName, cache = 15000) -clientDB = MetakitDatabaseString("var/db_data", "accounts", cache = 100) -msgDB = MetakitDatabaseString("var/db_data", "messages", cache = 1000) - -if optRestore: - gameDB.restore("var/backup-game_Alpha.osbackup") - clientDB.restore("var/backup-accounts.osbackup") - msgDB.restore("var/backup-messages.osbackup") - -# initialize game -log.message('Initializing game \'%s\'...' % gameName) - -log.debug("Initializing issue manager") -issueMngr = IssueMngr() -log.debug("Initializing client manager") -clientMngr = ClientMngr(clientDB) -log.debug("Initializing message manager") -msgMngr = MsgMngr(msgDB) - -log.debug("Initializing game manager") -game = GameMngr(gameName, clientMngr, msgMngr, gameDB) - -if optReset: - # reset game - log.message('Resetting game \'%s\'...' % gameName) - game.reset() -else: - # normal operations - game.init() - - if optUpgrade: - game.upgrade() - msgMngr.upgrade() - - game.start() - - server.init(clientMngr) - server.register(game) - - server.xmlrpcPublish('clientmngr', clientMngr) - server.xmlrpcPublish('issuemngr', issueMngr) - - log.message('Initialized. Starting server...') - - try: - import psyco - psyco.full() - log.message("Using psyco with full acceleration") - except ImportError: - log.message("NOT using psyco") - server.start() Copied: branches/ospace_0.5/server/ospace-server.py (from rev 322, branches/ospace_0.5/server/ospace-server) =================================================================== --- branches/ospace_0.5/server/ospace-server.py (rev 0) +++ branches/ospace_0.5/server/ospace-server.py 2011-12-28 19:02:47 UTC (rev 324) @@ -0,0 +1,127 @@ +#!/usr/bin/python +# +# Copyright 2001 - 2012 Ludek Smid [http://www.ospace.net/] +# +# This file is part of Outer Space. +# +# Outer Space is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# Outer Space is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Outer Space; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +import os +import sys + +# setup system path +baseDir = os.path.abspath(os.path.dirname(__file__)) + +sys.path.insert(0, os.path.join(baseDir, "lib")) +sys.path.insert(0, os.path.join(baseDir, "..", "client-ai")) + +import atexit +import optparse + +from ai_parser import AIList + +parser = optparse.OptionParser() +parser.add_option("", "--configdir", dest="configDir", + metavar="DIRECTORY", + default="var", + help="Override default configuration directory", +) +parser.add_option("", "--configfile", dest="configFile", + metavar="DIRECTORY", + default="config.ini", + help="Override default name of configuration file", +) +parser.add_option("", "--restore", dest="restore", + metavar="STRING", + default=None, + help="Restore from backup files beginning with STRING", +) +parser.add_option("", "--reset", dest="reset", + action="store_true", default=False, + help="Sets server to reset itself" +) +parser.add_option("", "--upgrade", dest="upgrade", + action="store_true", default=False, + help="Server will undergo upgrade routine" +) +parser.add_option("", "--devel", dest="devel", + action="store_true", default=False, + help="Server will run in debug mode", +) + +options, args = parser.parse_args() + +if args: + parser.error("No additional arguments are supported") + +# legacy logger +from ige import log +log.setMessageLog(os.path.join(options.configDir, 'logs/messages.log')) +log.setErrorLog(os.path.join(options.configDir, 'logs/errors.log')) + +import ige.version +log.message("Outer Space %s" % ige.version.versionStringFull) + +# record my pid +pidFd = os.open(os.path.join(options.configDir, "server.pid"), os.O_CREAT | os.O_EXCL | os.O_WRONLY) +os.write(pidFd, str(os.getpid())) +# TODO: check if server.pid points to the running process + +gameServer = None + +# define and register exit function +def cleanup(): + """Shutdown game properly""" + try: + if gameServer: + log.message('Shutting down game...') + gameServer.shutdown() + except: + log.exception("Shutdown of the server failed") + + # delete my pid + os.close(pidFd) + os.remove(os.path.join(options.configDir, "server.pid")) + log.message("GAME SHUT DOWN") + +atexit.register(cleanup) + +# startup game +import ige +import ige.RPCServer as server + +# set runtime mode +ige.setRuntimeMode(not options.devel) + +# create game server +from ige.GameServer import GameServer + +gameServer = GameServer(os.path.join(options.configDir, options.configFile)) + +server.init(gameServer.clientMngr) +for game in gameServer.games: + server.register(game) + +log.message('Initialized. Starting server...') + +try: + import psyco + psyco.full() + log.message("Using psyco with full acceleration") +except ImportError: + log.message("NOT using psyco") + +server.start() \ No newline at end of file Property changes on: branches/ospace_0.5/server/ospace-server.py ___________________________________________________________________ Added: svn:executable + * Modified: branches/ospace_0.5/server/run.py =================================================================== --- branches/ospace_0.5/server/run.py 2011-12-05 21:53:41 UTC (rev 323) +++ branches/ospace_0.5/server/run.py 2011-12-28 19:02:47 UTC (rev 324) @@ -173,7 +173,7 @@ from ige.SQLiteDatabase import Database, DatabaseString # set type of generated galaxies if not config.server.newgalaxytype: - config.server.newgalaxytype = 'Circle42P' + config.server.newgalaxytype = 'Circle9P' log.debug("Creating databases...") gameDB = Database(os.path.join(options.configDir,"db_data"), "game_%s" % gameName, cache = 15000) @@ -204,7 +204,7 @@ log.debug("Initializing issue manager") issueMngr = IssueMngr() log.debug("Initializing client manager") -clientMngr = ClientMngr(clientDB, config, options.configDir) +clientMngr = ClientMngr(clientDB, config.server.authmethod, options.configDir) log.debug("Initializing message manager") msgMngr = MsgMngr(msgDB) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qa...@us...> - 2011-12-05 21:53:48
|
Revision: 323 http://ospace.svn.sourceforge.net/ospace/?rev=323&view=rev Author: qark Date: 2011-12-05 21:53:41 +0000 (Mon, 05 Dec 2011) Log Message: ----------- - Game information now exported to json. [Qark] - Server welcome page added. [Qark] Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py branches/ospace_0.5/server/lib/medusa/status_handler.py Added Paths: ----------- branches/ospace_0.5/server/website/ branches/ospace_0.5/server/website/background.jpg branches/ospace_0.5/server/website/block_bg.png branches/ospace_0.5/server/website/index.html branches/ospace_0.5/server/website/styles.css branches/ospace_0.5/server/website/top_bar_bg.png Property Changed: ---------------- branches/ospace_0.5/server/ Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2011-12-05 17:28:39 UTC (rev 322) +++ branches/ospace_0.5/ChangeLog.txt 2011-12-05 21:53:41 UTC (rev 323) @@ -8,6 +8,8 @@ [2011-12-05] - Fixed galaxy restart issue. [Qark] +- Game information now exported to json. [Qark] +- Server welcome page added. [Qark] [2011-11-14] - Fixed AI scripts deployment issues. [Qark] Property changes on: branches/ospace_0.5/server ___________________________________________________________________ Modified: svn:ignore - website build var ticker.py *.sh *.bat exportnews crontab MANIFEST + build var ticker.py *.sh *.bat exportnews crontab MANIFEST Modified: branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py 2011-12-05 17:28:39 UTC (rev 322) +++ branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py 2011-12-05 21:53:41 UTC (rev 323) @@ -18,6 +18,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +import json import random, os, time, copy import ige @@ -402,60 +403,34 @@ os.makedirs('website/%s' % self.gameID) except OSError: pass - # save info - fh = open('website/%s/info_cz.html' % self.gameID, 'w') + # create structure to save + stats = dict() universe = self.db[OID_UNIVERSE] - print >> fh, '<strong><big>·</big></strong> Hracu: <strong>%d</strong><br>' % len(universe.players) - turn = universe.turn - print >> fh, '<strong><big>·</big></strong> Tah: <strong>%d:%02d</strong><br>' % (turn / 24, turn % 24) + stats["players"] = len(universe.players) + stats["turn"] = "%d:%02d" % (universe.turn / 24, universe.turn % 24) + galaxies = list() + stats["galaxies"] = galaxies for galaxyID in universe.galaxies: galaxy = self.db[galaxyID] - print >> fh, '<strong><big>·</big></strong> Galaxie <strong>%s</strong> [<a href="http://ospace.net:9080/%s/galaxy%d.html">stats</a>]<br>' % ( - galaxy.name, self.gameID, galaxyID + galaxyStats = dict( + name = galaxy.name, + url = "http://www.ospace.net:9080/%s/galaxy%d.html" % (self.gameID, galaxyID), + freePositions = len(galaxy.startingPos), + players = 0, + rebels = 0, + age = int(((time.time() - galaxy.creationTime) / (24 * 3600))), + running = galaxy.timeEnabled and not galaxy.timeStopped, ) - aiPlayers = 0 for playerID in universe.players: player = self.db[playerID] - if player.type == T_AIPLAYER and galaxy.oid in player.galaxies \ - and player.planets: - aiPlayers += 1 - if len(galaxy.startingPos) or aiPlayers: - print >> fh, ' Volnych pozic: <strong>%d + %d</strong><br>' % ( - len(galaxy.startingPos), - aiPlayers, - ) - print >> fh, ' Stari: <strong>%d</strong> dni<br>' % \ - ((time.time() - galaxy.creationTime) / (24 * 3600)) - if not galaxy.timeEnabled or galaxy.timeStopped: - print >> fh, ' <strong>Cas zastaven</strong><br>' - fh.close() - # save info - fh = open('website/%s/info_en.html' % self.gameID, 'w') - universe = self.db[OID_UNIVERSE] - print >> fh, '<strong><big>·</big></strong> Players: <strong>%d</strong><br>' % len(universe.players) - turn = universe.turn - print >> fh, '<strong><big>·</big></strong> Turn: <strong>%d:%02d</strong><br>' % (turn / 24, turn % 24) - for galaxyID in universe.galaxies: - galaxy = self.db[galaxyID] - print >> fh, '<strong><big>·</big></strong> Galaxy <strong>%s</strong> [<a href="http://ospace.net:9080/%s/galaxy%d.html">stats</a>]<br>' % ( - galaxy.name, self.gameID, galaxyID - ) - aiPlayers = 0 - for playerID in universe.players: - player = self.db[playerID] - if player.type == T_AIPLAYER and galaxy.oid in player.galaxies \ - and player.planets: - aiPlayers += 1 - if len(galaxy.startingPos) or aiPlayers: - print >> fh, ' Free positions: <strong>%d + %d</strong><br>' % ( - len(galaxy.startingPos), - aiPlayers, - ) - print >> fh, ' Age: <strong>%d</strong> days<br>' % \ - ((time.time() - galaxy.creationTime) / (24 * 3600)) - if not galaxy.timeEnabled or galaxy.timeStopped: - print >> fh, ' <strong>Time is stopped.</strong><br>' - fh.close() + if galaxy.oid not in player.galaxies: + continue + if player.type == T_PLAYER: + galaxyStats["players"] += 1 + elif player.type == T_AIPLAYER: + galaxyStats["rebels"] += 1 + galaxies.append(galaxyStats) + json.dump(stats, open("website/%s/info.json" % self.gameID, "w")) def generateStats(self): """ Generate games statistics """ @@ -668,18 +643,17 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> - <title>IGE - Outer Space Statistics [Game %s]</title> - <link rel="STYLESHEET" href="../old/style.css" type="text/css"> + <title>Outer Space Statistics for Game %s</title> + <link rel="STYLESHEET" href="../styles.css" type="text/css"> </head> <body> <center> +<h1>Statistics for galaxy %s%s</h1> + <table cellspacing=2 border=0 cellpadding=5 width="80%%" class="main"> <tr> - <td class="header">Statistics for galaxy %s%s</td> -</tr> -<tr> <td valign="top"> <!-- body start --> ''' Modified: branches/ospace_0.5/server/lib/medusa/status_handler.py =================================================================== --- branches/ospace_0.5/server/lib/medusa/status_handler.py 2011-12-05 17:28:39 UTC (rev 322) +++ branches/ospace_0.5/server/lib/medusa/status_handler.py 2011-12-05 21:53:41 UTC (rev 323) @@ -68,21 +68,29 @@ request.push ( '<html>' '<head>' - '<title>Medusa Status Reports</title>' - '<link rel="STYLESHEET" href="../style.css" type="text/css">' + '<title>Outer Space Status Reports</title>' + '<link rel="STYLESHEET" href="styles.css" type="text/css">' '</head>' - '<body bgcolor="#ffffff">' - '<h1>Medusa Status Reports</h1>' + '<body>' + '<div class="main">' + '<div class="panel">' + '<div class="block">' + '<h1>Outer Space Status Reports</h1>' + '<div class="block-txt">' '<b>Up:</b> %s' % up_time ) for i in range(len(self.objects)): request.push (self.objects[i].status()) - request.push ('<hr noshade>\r\n') request.push ( # This is dangerous # '<p><a href="%s/channel_list">Channel List</a>' # '<hr noshade>' # '<img src="%s/medusa.gif" align=right width=%d height=%d>' + '</div>' + '</div>' + '<div class="footer">© 2001 - 2011 Ludek Smid, <a href="http://www.ospace.net/">www.ospace.net</a></div>' + '</div>' + '</div>' '</body></html>' % ( # self.statusdir, # self.statusdir, Property changes on: branches/ospace_0.5/server/website ___________________________________________________________________ Added: svn:ignore + Alpha res.txt Added: branches/ospace_0.5/server/website/background.jpg =================================================================== (Binary files differ) Property changes on: branches/ospace_0.5/server/website/background.jpg ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: branches/ospace_0.5/server/website/block_bg.png =================================================================== (Binary files differ) Property changes on: branches/ospace_0.5/server/website/block_bg.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: branches/ospace_0.5/server/website/index.html =================================================================== --- branches/ospace_0.5/server/website/index.html (rev 0) +++ branches/ospace_0.5/server/website/index.html 2011-12-05 21:53:41 UTC (rev 323) @@ -0,0 +1,31 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> +<head> + <title>Outer Space Server</title> + <link rel="STYLESHEET" href="/styles.css" type="text/css"> +</head> +<body> + +<div class="main"> +<div class="panel"> +<div class="block"> + +<h1>Outer Space Server</h1> + +<div class="block-txt"> +<a href="status"><h2>Run-time status</h2></a> + +</div> + +</div> + +<div class="footer">© 2001 - 2011 Ludek Smid, <a href="http://www.ospace.net/">www.ospace.net</a></div> + +</div> + + +</div> + + +</body> +</html> Property changes on: branches/ospace_0.5/server/website/index.html ___________________________________________________________________ Added: svn:mime-type + text/plain Added: branches/ospace_0.5/server/website/styles.css =================================================================== --- branches/ospace_0.5/server/website/styles.css (rev 0) +++ branches/ospace_0.5/server/website/styles.css 2011-12-05 21:53:41 UTC (rev 323) @@ -0,0 +1,261 @@ +@charset "utf-8"; + +html { + height: 100%; +} + +html,body,ul,ol,li,p,h1,h2,h3,h4,h5,h6,form,a,img { + margin: 0px; + padding: 0px; + border: 0px; +} + +ol,ul { + padding-left: 2em; + +} + +body { + height: 100%; + font-weight: normal; + font: 12px Arial, Helvetica, sans-serif; + text-align: justify; + width: 100%; + background: url(background.jpg) no-repeat center top; + background-color: #181829; + color: #ffffff; +} + +a { +color:#8fb6e5; +text-decoration:underline; +} + + +a:hover { +text-decoration:none; +} + +.main { + width: 1000px; + margin: 0 auto; + height: auto; + /* border: 1px solid red; */ +} + +/* web2py specific */ +div.flash { + padding: 5px 15px 5px 15px; + margin: 0px 0px 7px 7px; + width: 956px; + background: url(block_bg.png) repeat; + font-weight: bold; + text-align: right; + color: #e09c43; + -moz-border-radius:0px 0px 7px 7px; + border-radius:0px 0px 7px 7px; + border:1px solid #3d444e; +} + +/* Menu section */ +.topbar { + margin-top: 0px; + padding-left: 0px; + padding-right: 0px; + width: 1000px; + height: 45px; + background: url(top_bar_bg.png) left top repeat-x; + -moz-border-radius:0px 0px 7px 7px; + border-radius:0px 0px 7px 7px; + text-shadow: 0px 1px 1px #fff; + color: #737373; +} + +.topbar a { + color: #737373; + text-decoration:none; +} + +.topbar a:hover { + color: #5C5C5C; + text-decoration:none; +} + +.logo { + float: left; + margin-top: -2px; + padding: 0px; + border: 0px; + height: 45px; + /* border: 1px solid red; */ +} + +.logo img { + padding-top: 2px; + /* border: 1px solid red; */ +} + +.menu { + padding-top: 18px; + padding-bottom: 0px; + padding-right: 1em; + margin: 0px; + float: right; + height: 20px; + font-weight: bold; + /* border: 1px solid red; */ +} + +.clear { + clear: both; +} + +/* About section */ +.about { + clear: both; + margin-top: 15px; + /* border: 1px solid red; */ +} + +.about_main { + margin-right: 315px; + background: url(block_bg.png) repeat; + font-size: large; + padding: 20px; + height: 150px; + -moz-border-radius:7px 7px 7px 7px; + border-radius:7px 7px 7px 7px; + border:1px solid #3d444e; +} + +.about_main img { + float: left; + padding-right: 20px; +} + +.about_sidebar { + float: right; + width: 300px; + font-size: 40px; +} + +.about_sidebar #button { + text-align: left; + font-weight: bold; + padding: 6px; + padding-left: 0.5em; + margin-bottom: 5px; + background: url(block_bg.png) repeat; + border:1px solid #3d444e; + border-left:15px solid #a3abb6; + -moz-border-radius:0px 7px 7px 0px; + border-radius:0px 7px 7px 0px; +} + +.about_sidebar a { + color:#d9dbe0; + text-decoration:none; +} + +.about_sidebar a:hover { + color:#8fb6e5; + text-decoration:none; +} + +/* Main part of the page */ + +.panel { + min-height: 900px; +} + +.block { + margin-top: 25px; + width: 685px; + background: url(block_bg.png) repeat; + -moz-border-radius:7px 7px 7px 7px; + border-radius:7px 7px 7px 7px; + border:1px solid #3d444e; +} + +.block-txt { + padding-left: 15px; + padding-right: 15px; + padding-top: 5px; + padding-bottom: 15px; + line-height: 20px; +} + +.block h1 { + padding-left: 15px; + padding-top: 5px; + width: 670px; + height:40px; + margin-bottom: 0.5em; + line-height: 35px; + background: url(top_bar_bg.png) repeat; + -moz-border-radius:7px 7px 0px 0px; + border-radius:7px 7px 0px 0px; + text-shadow: 0px 1px 1px #fff; + color: #737373; +} + +.footer { + width: 655px; + padding: 15px; + background: url(block_bg.png) repeat; + -moz-border-radius:7px 7px 7px 7px; + border-radius:7px 7px 7px 7px; + border:1px solid #3d444e; + margin-bottom: 45px; +} + +/* Messages and forums */ +.message_footer { + margin-top: 0.5em; + text-align: right; + font-size: smaller; +} + + +table.forums { + width: 100%; + border-bottom: 1px solid #888888; + border-top: 1px solid #888888; +} + +table.forums th { + text-align: left; +} + +table.forums td.name { + width: 60%; +} + +table.forums td.posts { + width: 20%; +} + + +table.forums td.lastpost { + width: 20%; +} + +table.forums a { + display: block; + border: 0; +} + +table.forums a:hover { +} + +ul.forums{ + list-style-type: none; + padding: 0; + margin: 0; +} + +ul.forums li { + border-bottom: 1px dotted #888888; + padding-bottom: 0.25em; + margin-bottom: 0.25em; +} Property changes on: branches/ospace_0.5/server/website/styles.css ___________________________________________________________________ Added: svn:mime-type + text/plain Added: branches/ospace_0.5/server/website/top_bar_bg.png =================================================================== (Binary files differ) Property changes on: branches/ospace_0.5/server/website/top_bar_bg.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qa...@us...> - 2011-12-05 17:28:49
|
Revision: 322 http://ospace.svn.sourceforge.net/ospace/?rev=322&view=rev Author: qark Date: 2011-12-05 17:28:39 +0000 (Mon, 05 Dec 2011) Log Message: ----------- - Fixed galaxy restart issue Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/server/lib/ige/IssueMngr.py branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2011-11-22 21:22:09 UTC (rev 321) +++ branches/ospace_0.5/ChangeLog.txt 2011-12-05 17:28:39 UTC (rev 322) @@ -6,12 +6,9 @@ - $Author$ - $Revision$ -[2011-11-22] -- Added support for RSA authentication. [Qark] +[2011-12-05] +- Fixed galaxy restart issue. [Qark] -[2011-11-15] -- MD5 authentication is now backward compatible. [Qark] - [2011-11-14] - Fixed AI scripts deployment issues. [Qark] - Added support for different authentication schemes. Supported are PLAIN, MD5 (default), and SHA256. [Qark] Modified: branches/ospace_0.5/server/lib/ige/IssueMngr.py =================================================================== --- branches/ospace_0.5/server/lib/ige/IssueMngr.py 2011-11-22 21:22:09 UTC (rev 321) +++ branches/ospace_0.5/server/lib/ige/IssueMngr.py 2011-12-05 17:28:39 UTC (rev 322) @@ -35,7 +35,7 @@ msg = MIMEText(text) msg["Subject"] = "Outer Space Issue %s" % faultID msg["From"] = "gam...@os..." - mgs["To"] = "qa...@os..." + msg["To"] = "qa...@os..." smtp = smtplib.SMTP("localhost") smtp.sendmail( "gam...@os...", Modified: branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py 2011-11-22 21:22:09 UTC (rev 321) +++ branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py 2011-12-05 17:28:39 UTC (rev 322) @@ -490,7 +490,7 @@ log.debug("Deleting galaxy", galaxyID) self.cmd(galaxy).delete(tran, galaxy) if restart: - self.cmd(obj).createNewGalaxy(self, tran, obj, oldX, oldY, oldName) + self.cmd(obj).createNewGalaxy(tran, obj, oldX, oldY, oldName) restartGalaxy.public = 1 restartGalaxy.accLevel = AL_NONE @@ -516,7 +516,7 @@ log.debug("Deleting galaxy", galaxyID) self.cmd(galaxy).delete(tran, galaxy) if restart: - self.cmd(obj).createNewGalaxy(self, tran, obj, oldX, oldY, oldName) + self.cmd(obj).createNewGalaxy(tran, obj, oldX, oldY, oldName) restartGalaxy2.public = 1 restartGalaxy2.accLevel = AL_ADMIN This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qa...@us...> - 2011-11-22 21:22:18
|
Revision: 321 http://ospace.svn.sourceforge.net/ospace/?rev=321&view=rev Author: qark Date: 2011-11-22 21:22:09 +0000 (Tue, 22 Nov 2011) Log Message: ----------- - Added support for RSA authentication. [Qark] Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/server/lib/ige/Authentication.py Added Paths: ----------- branches/ospace_0.5/server/lib/pyasn1/ branches/ospace_0.5/server/lib/pyasn1/__init__.py branches/ospace_0.5/server/lib/pyasn1/codec/ branches/ospace_0.5/server/lib/pyasn1/codec/__init__.py branches/ospace_0.5/server/lib/pyasn1/codec/ber/ branches/ospace_0.5/server/lib/pyasn1/codec/ber/__init__.py branches/ospace_0.5/server/lib/pyasn1/codec/ber/decoder.py branches/ospace_0.5/server/lib/pyasn1/codec/ber/encoder.py branches/ospace_0.5/server/lib/pyasn1/codec/ber/eoo.py branches/ospace_0.5/server/lib/pyasn1/codec/cer/ branches/ospace_0.5/server/lib/pyasn1/codec/cer/__init__.py branches/ospace_0.5/server/lib/pyasn1/codec/cer/decoder.py branches/ospace_0.5/server/lib/pyasn1/codec/cer/encoder.py branches/ospace_0.5/server/lib/pyasn1/codec/der/ branches/ospace_0.5/server/lib/pyasn1/codec/der/__init__.py branches/ospace_0.5/server/lib/pyasn1/codec/der/decoder.py branches/ospace_0.5/server/lib/pyasn1/codec/der/encoder.py branches/ospace_0.5/server/lib/pyasn1/compat/ branches/ospace_0.5/server/lib/pyasn1/compat/__init__.py branches/ospace_0.5/server/lib/pyasn1/compat/octets.py branches/ospace_0.5/server/lib/pyasn1/error.py branches/ospace_0.5/server/lib/pyasn1/type/ branches/ospace_0.5/server/lib/pyasn1/type/__init__.py branches/ospace_0.5/server/lib/pyasn1/type/base.py branches/ospace_0.5/server/lib/pyasn1/type/char.py branches/ospace_0.5/server/lib/pyasn1/type/constraint.py branches/ospace_0.5/server/lib/pyasn1/type/error.py branches/ospace_0.5/server/lib/pyasn1/type/namedtype.py branches/ospace_0.5/server/lib/pyasn1/type/namedval.py branches/ospace_0.5/server/lib/pyasn1/type/tag.py branches/ospace_0.5/server/lib/pyasn1/type/tagmap.py branches/ospace_0.5/server/lib/pyasn1/type/univ.py branches/ospace_0.5/server/lib/pyasn1/type/useful.py branches/ospace_0.5/server/lib/rsa/ branches/ospace_0.5/server/lib/rsa/__init__.py branches/ospace_0.5/server/lib/rsa/_version133.py branches/ospace_0.5/server/lib/rsa/_version200.py branches/ospace_0.5/server/lib/rsa/bigfile.py branches/ospace_0.5/server/lib/rsa/cli.py branches/ospace_0.5/server/lib/rsa/common.py branches/ospace_0.5/server/lib/rsa/core.py branches/ospace_0.5/server/lib/rsa/key.py branches/ospace_0.5/server/lib/rsa/pem.py branches/ospace_0.5/server/lib/rsa/pkcs1.py branches/ospace_0.5/server/lib/rsa/prime.py branches/ospace_0.5/server/lib/rsa/randnum.py branches/ospace_0.5/server/lib/rsa/transform.py branches/ospace_0.5/server/lib/rsa/util.py branches/ospace_0.5/server/lib/rsa/varblock.py Property Changed: ---------------- branches/ospace_0.5/client-pygame/ Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2011-11-15 07:50:47 UTC (rev 320) +++ branches/ospace_0.5/ChangeLog.txt 2011-11-22 21:22:09 UTC (rev 321) @@ -6,6 +6,9 @@ - $Author$ - $Revision$ +[2011-11-22] +- Added support for RSA authentication. [Qark] + [2011-11-15] - MD5 authentication is now backward compatible. [Qark] Property changes on: branches/ospace_0.5/client-pygame ___________________________________________________________________ Modified: svn:ignore - var MANIFEST build res.ext + var MANIFEST build res.ext var* Modified: branches/ospace_0.5/server/lib/ige/Authentication.py =================================================================== --- branches/ospace_0.5/server/lib/ige/Authentication.py 2011-11-15 07:50:47 UTC (rev 320) +++ branches/ospace_0.5/server/lib/ige/Authentication.py 2011-11-22 21:22:09 UTC (rev 321) @@ -1,11 +1,50 @@ -from ige import SecurityException +import binascii +from ige import SecurityException, log import hashlib +import os +import rsa import time # default method is set to MD5 for backward compatibility # with version 0.5.68 (revision 308) defaultMethod = "md5" +# support for RSA keys +publicKey = None +privateKey = None + +def createRSAKeys(): + """Load or generate and save RSA keys""" + global publicKey, privateKey + if os.path.exists("var/private.pem"): + log.message("Loading PRIVATE RSA key") + privateKey = rsa.PrivateKey.load_pkcs1(open("var/private.pem", "rb").read()) + if os.path.exists("var/public.pem"): + log.message("Loading PUBLIC RSA key") + publicKey = rsa.PublicKey.load_pkcs1(open("var/public.pem", "rb").read()) + if privateKey and publicKey: + return + # no keys, let's generate them + log.message("Generating RSA keys, please wait...") + publicKey, privateKey = rsa.newkeys(2048) + open("var/public.pem", "w").write(publicKey.save_pkcs1()) + open("var/private.pem", "w").write(privateKey.save_pkcs1()) + +def getPublicKey(): + """Get current RSA public key""" + global publicKey + if not publicKey: + createRSAKeys() + return publicKey + +def getPrivateKey(): + """Get current RSA private key""" + global privateKey + if not privateKey: + createRSAKeys() + return privateKey + +# def getMethod(challenge): return challenge.split(":")[0] @@ -17,10 +56,13 @@ return "md5:" + hashlib.md5(str(time.time())).hexdigest() elif method == "sha256": return "sha256:" + hashlib.sha256(str(time.time())).hexdigest() + elif method == "rsa": + publicKey = getPublicKey() + return "rsa:%s:%s" % (publicKey.n, publicKey.e) raise SecurityException("Unsupported authentication method %s" % str(method)) def encode(password, challenge): - """Encodes password using auth method specified in the challenge""" + """Encode password using auth method specified in the challenge""" method = getMethod(challenge) if method == "plain": return password @@ -28,10 +70,14 @@ return hashlib.md5(password + challenge).hexdigest() elif method == "sha256": return hashlib.sha256(password + challenge).hexdigest() + elif method == "rsa": + dummy, n, e = challenge.split(":") + key = rsa.PublicKey(int(n), int(e)) + return binascii.hexlify(rsa.encrypt(password, key)) raise SecurityException("Unsupported authentication method %s" % str(method)) def verify(encodedPassword, password, challenge): - """Verifies password based on client encoded password and auth method""" + """Verify password based on client encoded password and auth method""" method = getMethod(challenge) if method == "plain": return encodedPassword == password @@ -39,4 +85,6 @@ return hashlib.md5(password + challenge).hexdigest() == encodedPassword elif method == "sha256": return hashlib.sha256(password + challenge).hexdigest() == encodedPassword + elif method == "rsa": + return rsa.decrypt(binascii.unhexlify(encodedPassword), getPrivateKey()) == password raise SecurityException("Unsupported authentication method %s" % str(method)) Added: branches/ospace_0.5/server/lib/pyasn1/__init__.py =================================================================== --- branches/ospace_0.5/server/lib/pyasn1/__init__.py (rev 0) +++ branches/ospace_0.5/server/lib/pyasn1/__init__.py 2011-11-22 21:22:09 UTC (rev 321) @@ -0,0 +1 @@ +majorVersionId = '1' Property changes on: branches/ospace_0.5/server/lib/pyasn1/__init__.py ___________________________________________________________________ Added: svn:mime-type + text/plain Property changes on: branches/ospace_0.5/server/lib/pyasn1/codec/__init__.py ___________________________________________________________________ Added: svn:mime-type + text/plain Property changes on: branches/ospace_0.5/server/lib/pyasn1/codec/ber/__init__.py ___________________________________________________________________ Added: svn:mime-type + text/plain Added: branches/ospace_0.5/server/lib/pyasn1/codec/ber/decoder.py =================================================================== --- branches/ospace_0.5/server/lib/pyasn1/codec/ber/decoder.py (rev 0) +++ branches/ospace_0.5/server/lib/pyasn1/codec/ber/decoder.py 2011-11-22 21:22:09 UTC (rev 321) @@ -0,0 +1,746 @@ +# BER decoder +from pyasn1.type import tag, base, univ, char, useful, tagmap +from pyasn1.codec.ber import eoo +from pyasn1.compat.octets import oct2int, octs2ints +from pyasn1 import error + +class AbstractDecoder: + protoComponent = None + def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun): + raise error.PyAsn1Error('Decoder not implemented for %s' % tagSet) + + def indefLenValueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun): + raise error.PyAsn1Error('Indefinite length mode decoder not implemented for %s' % tagSet) + +class AbstractSimpleDecoder(AbstractDecoder): + def _createComponent(self, asn1Spec, tagSet, value=None): + if asn1Spec is None: + return self.protoComponent.clone(value, tagSet) + elif value is None: + return asn1Spec + else: + return asn1Spec.clone(value) + +class AbstractConstructedDecoder(AbstractDecoder): + def _createComponent(self, asn1Spec, tagSet, value=None): + if asn1Spec is None: + return self.protoComponent.clone(tagSet) + else: + return asn1Spec.clone() + +class EndOfOctetsDecoder(AbstractSimpleDecoder): + def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun): + return eoo.endOfOctets, substrate[:length] + +class ExplicitTagDecoder(AbstractSimpleDecoder): + def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun): + return decodeFun(substrate[:length], asn1Spec, tagSet, length) + + def indefLenValueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun): + value, substrate = decodeFun(substrate, asn1Spec, tagSet, length) + terminator, substrate = decodeFun(substrate) + if terminator == eoo.endOfOctets: + return value, substrate + else: + raise error.PyAsn1Error('Missing end-of-octets terminator') + +explicitTagDecoder = ExplicitTagDecoder() + +class IntegerDecoder(AbstractSimpleDecoder): + protoComponent = univ.Integer(0) + precomputedValues = { + '\x00': 0, + '\x01': 1, + '\x02': 2, + '\x03': 3, + '\x04': 4, + '\x05': 5, + '\x06': 6, + '\x07': 7, + '\x08': 8, + '\x09': 9, + '\xff': -1, + '\xfe': -2, + '\xfd': -3, + '\xfc': -4, + '\xfb': -5 + } + + def _valueFilter(self, value): + try: + return int(value) + except OverflowError: + return value + + def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, length, + state, decodeFun): + substrate = substrate[:length] + if not substrate: + raise error.PyAsn1Error('Empty substrate') + if substrate in self.precomputedValues: + value = self.precomputedValues[substrate] + else: + firstOctet = oct2int(substrate[0]) + if firstOctet & 0x80: + value = -1 + else: + value = 0 + for octet in substrate: + value = value << 8 | oct2int(octet) + value = self._valueFilter(value) + return self._createComponent(asn1Spec, tagSet, value), substrate + +class BooleanDecoder(IntegerDecoder): + protoComponent = univ.Boolean(0) + def _valueFilter(self, value): + if value: + return 1 + else: + return 0 + +class BitStringDecoder(AbstractSimpleDecoder): + protoComponent = univ.BitString(()) + def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, length, + state, decodeFun): + substrate = substrate[:length] + if tagSet[0][1] == tag.tagFormatSimple: # XXX what tag to check? + if not substrate: + raise error.PyAsn1Error('Missing initial octet') + trailingBits = oct2int(substrate[0]) + if trailingBits > 7: + raise error.PyAsn1Error( + 'Trailing bits overflow %s' % trailingBits + ) + substrate = substrate[1:] + lsb = p = 0; l = len(substrate)-1; b = () + while p <= l: + if p == l: + lsb = trailingBits + j = 7 + o = oct2int(substrate[p]) + while j >= lsb: + b = b + ((o>>j)&0x01,) + j = j - 1 + p = p + 1 + return self._createComponent(asn1Spec, tagSet, b), '' + r = self._createComponent(asn1Spec, tagSet, ()) + if not decodeFun: + return r, substrate + while substrate: + component, substrate = decodeFun(substrate) + r = r + component + return r, substrate + + def indefLenValueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun): + r = self._createComponent(asn1Spec, tagSet, '') + if not decodeFun: + return r, substrate + while substrate: + component, substrate = decodeFun(substrate) + if component == eoo.endOfOctets: + break + r = r + component + else: + raise error.SubstrateUnderrunError( + 'No EOO seen before substrate ends' + ) + return r, substrate + +class OctetStringDecoder(AbstractSimpleDecoder): + protoComponent = univ.OctetString('') + def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, length, + state, decodeFun): + substrate = substrate[:length] + if tagSet[0][1] == tag.tagFormatSimple: # XXX what tag to check? + return self._createComponent(asn1Spec, tagSet, substrate), '' + r = self._createComponent(asn1Spec, tagSet, '') + if not decodeFun: + return r, substrate + while substrate: + component, substrate = decodeFun(substrate) + r = r + component + return r, substrate + + def indefLenValueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun): + r = self._createComponent(asn1Spec, tagSet, '') + if not decodeFun: + return r, substrate + while substrate: + component, substrate = decodeFun(substrate) + if component == eoo.endOfOctets: + break + r = r + component + else: + raise error.SubstrateUnderrunError( + 'No EOO seen before substrate ends' + ) + return r, substrate + +class NullDecoder(AbstractSimpleDecoder): + protoComponent = univ.Null('') + def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun): + substrate = substrate[:length] + r = self._createComponent(asn1Spec, tagSet) + if substrate: + raise error.PyAsn1Error('Unexpected substrate for Null') + return r, substrate + +class ObjectIdentifierDecoder(AbstractSimpleDecoder): + protoComponent = univ.ObjectIdentifier(()) + def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, length, + state, decodeFun): + substrate = substrate[:length] + if not substrate: + raise error.PyAsn1Error('Empty substrate') + oid = (); index = 0 + # Get the first subid + subId = oct2int(substrate[index]) + oid = oid + divmod(subId, 40) + + index = index + 1 + substrateLen = len(substrate) + + while index < substrateLen: + subId = oct2int(substrate[index]) + if subId < 128: + oid = oid + (subId,) + index = index + 1 + else: + # Construct subid from a number of octets + nextSubId = subId + subId = 0 + while nextSubId >= 128 and index < substrateLen: + subId = (subId << 7) + (nextSubId & 0x7F) + index = index + 1 + nextSubId = oct2int(substrate[index]) + if index == substrateLen: + raise error.SubstrateUnderrunError( + 'Short substrate for OID %s' % oid + ) + subId = (subId << 7) + nextSubId + oid = oid + (subId,) + index = index + 1 + return self._createComponent(asn1Spec, tagSet, oid), substrate[index:] + +class RealDecoder(AbstractSimpleDecoder): + protoComponent = univ.Real() + def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun): + substrate = substrate[:length] + if not length: + raise error.SubstrateUnderrunError('Short substrate for Real') + fo = oct2int(substrate[0]); substrate = substrate[1:] + if fo & 0x40: # infinite value + value = fo & 0x01 and '-inf' or 'inf' + elif fo & 0x80: # binary enoding + if fo & 0x11 == 0: + n = 1 + elif fo & 0x01: + n = 2 + elif fo & 0x02: + n = 3 + else: + n = oct2int(substrate[0]) + eo, substrate = substrate[:n], substrate[n:] + if not eo or not substrate: + raise error.PyAsn1Error('Real exponent screwed') + e = 0 + while eo: # exponent + e <<= 8 + e |= oct2int(eo[0]) + eo = eo[1:] + p = 0 + while substrate: # value + p <<= 8 + p |= oct2int(substrate[0]) + substrate = substrate[1:] + if fo & 0x40: # sign bit + p = -p + value = (p, 2, e) + elif fo & 0xc0 == 0: # character encoding + try: + if fo & 0x3 == 0x1: # NR1 + value = (int(substrate), 10, 0) + elif fo & 0x3 == 0x2: # NR2 + value = float(substrate) + elif fo & 0x3 == 0x3: # NR3 + value = float(substrate) + else: + raise error.SubstrateUnderrunError( + 'Unknown NR (tag %s)' % fo + ) + except ValueError: + raise error.SubstrateUnderrunError( + 'Bad character Real syntax' + ) + elif fo & 0xc0 == 0x40: # special real value + pass + else: + raise error.SubstrateUnderrunError( + 'Unknown encoding (tag %s)' % fo + ) + return self._createComponent(asn1Spec, tagSet, value), substrate + +class SequenceDecoder(AbstractConstructedDecoder): + protoComponent = univ.Sequence() + def _getComponentTagMap(self, r, idx): + try: + return r.getComponentTagMapNearPosition(idx) + except error.PyAsn1Error: + return + + def _getComponentPositionByType(self, r, t, idx): + return r.getComponentPositionNearType(t, idx) + + def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun): + substrate = substrate[:length] + r = self._createComponent(asn1Spec, tagSet) + idx = 0 + if not decodeFun: + return r, substrate + while substrate: + asn1Spec = self._getComponentTagMap(r, idx) + component, substrate = decodeFun( + substrate, asn1Spec + ) + idx = self._getComponentPositionByType( + r, component.getEffectiveTagSet(), idx + ) + r.setComponentByPosition(idx, component, asn1Spec is None) + idx = idx + 1 + r.setDefaultComponents() + r.verifySizeSpec() + return r, substrate + + def indefLenValueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun): + r = self._createComponent(asn1Spec, tagSet) + idx = 0 + while substrate: + asn1Spec = self._getComponentTagMap(r, idx) + if not decodeFun: + return r, substrate + component, substrate = decodeFun(substrate, asn1Spec) + if component == eoo.endOfOctets: + break + idx = self._getComponentPositionByType( + r, component.getEffectiveTagSet(), idx + ) + r.setComponentByPosition(idx, component, asn1Spec is None) + idx = idx + 1 + else: + raise error.SubstrateUnderrunError( + 'No EOO seen before substrate ends' + ) + r.setDefaultComponents() + r.verifySizeSpec() + return r, substrate + +class SequenceOfDecoder(AbstractConstructedDecoder): + protoComponent = univ.SequenceOf() + def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun): + substrate = substrate[:length] + r = self._createComponent(asn1Spec, tagSet) + asn1Spec = r.getComponentType() + idx = 0 + if not decodeFun: + return r, substrate + while substrate: + component, substrate = decodeFun( + substrate, asn1Spec + ) + r.setComponentByPosition(idx, component, asn1Spec is None) + idx = idx + 1 + r.verifySizeSpec() + return r, substrate + + def indefLenValueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun): + r = self._createComponent(asn1Spec, tagSet) + asn1Spec = r.getComponentType() + idx = 0 + if not decodeFun: + return r, substrate + while substrate: + component, substrate = decodeFun(substrate, asn1Spec) + if component == eoo.endOfOctets: + break + r.setComponentByPosition(idx, component, asn1Spec is None) + idx = idx + 1 + else: + raise error.SubstrateUnderrunError( + 'No EOO seen before substrate ends' + ) + r.verifySizeSpec() + return r, substrate + +class SetDecoder(SequenceDecoder): + protoComponent = univ.Set() + def _getComponentTagMap(self, r, idx): + return r.getComponentTagMap() + + def _getComponentPositionByType(self, r, t, idx): + nextIdx = r.getComponentPositionByType(t) + if nextIdx is None: + return idx + else: + return nextIdx + +class SetOfDecoder(SequenceOfDecoder): + protoComponent = univ.SetOf() + +class ChoiceDecoder(AbstractConstructedDecoder): + protoComponent = univ.Choice() + def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun): + substrate = substrate[:length] + r = self._createComponent(asn1Spec, tagSet) + if not decodeFun: + return r, substrate + if r.getTagSet() == tagSet: # explicitly tagged Choice + component, substrate = decodeFun( + substrate, r.getComponentTagMap() + ) + else: + component, substrate = decodeFun( + substrate, r.getComponentTagMap(), tagSet, length, state + ) + if isinstance(component, univ.Choice): + effectiveTagSet = component.getEffectiveTagSet() + else: + effectiveTagSet = component.getTagSet() + r.setComponentByType(effectiveTagSet, component, 0, asn1Spec is None) + return r, substrate + + indefLenValueDecoder = valueDecoder + +class AnyDecoder(AbstractSimpleDecoder): + protoComponent = univ.Any() + def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun): + if asn1Spec is None or \ + asn1Spec is not None and tagSet != asn1Spec.getTagSet(): + # untagged Any container, recover inner header substrate + length = length + len(fullSubstrate) - len(substrate) + substrate = fullSubstrate + substrate = substrate[:length] + return self._createComponent(asn1Spec, tagSet, value=substrate), '' + + def indefLenValueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, + length, state, decodeFun): + if asn1Spec is not None and tagSet == asn1Spec.getTagSet(): + # tagged Any type -- consume header substrate + header = '' + else: + # untagged Any, recover header substrate + header = fullSubstrate[:-len(substrate)] + + r = self._createComponent(asn1Spec, tagSet, header) + + # Any components do not inherit initial tag + asn1Spec = self.protoComponent + + if not decodeFun: + return r, substrate + while substrate: + component, substrate = decodeFun(substrate, asn1Spec) + if component == eoo.endOfOctets: + break + r = r + component + else: + raise error.SubstrateUnderrunError( + 'No EOO seen before substrate ends' + ) + return r, substrate + +# character string types +class UTF8StringDecoder(OctetStringDecoder): + protoComponent = char.UTF8String() +class NumericStringDecoder(OctetStringDecoder): + protoComponent = char.NumericString() +class PrintableStringDecoder(OctetStringDecoder): + protoComponent = char.PrintableString() +class TeletexStringDecoder(OctetStringDecoder): + protoComponent = char.TeletexString() +class VideotexStringDecoder(OctetStringDecoder): + protoComponent = char.VideotexString() +class IA5StringDecoder(OctetStringDecoder): + protoComponent = char.IA5String() +class GraphicStringDecoder(OctetStringDecoder): + protoComponent = char.GraphicString() +class VisibleStringDecoder(OctetStringDecoder): + protoComponent = char.VisibleString() +class GeneralStringDecoder(OctetStringDecoder): + protoComponent = char.GeneralString() +class UniversalStringDecoder(OctetStringDecoder): + protoComponent = char.UniversalString() +class BMPStringDecoder(OctetStringDecoder): + protoComponent = char.BMPString() + +# "useful" types +class GeneralizedTimeDecoder(OctetStringDecoder): + protoComponent = useful.GeneralizedTime() +class UTCTimeDecoder(OctetStringDecoder): + protoComponent = useful.UTCTime() + +tagMap = { + eoo.endOfOctets.tagSet: EndOfOctetsDecoder(), + univ.Integer.tagSet: IntegerDecoder(), + univ.Boolean.tagSet: BooleanDecoder(), + univ.BitString.tagSet: BitStringDecoder(), + univ.OctetString.tagSet: OctetStringDecoder(), + univ.Null.tagSet: NullDecoder(), + univ.ObjectIdentifier.tagSet: ObjectIdentifierDecoder(), + univ.Enumerated.tagSet: IntegerDecoder(), + univ.Real.tagSet: RealDecoder(), + univ.Sequence.tagSet: SequenceDecoder(), # conflicts with SequenceOf + univ.Set.tagSet: SetDecoder(), # conflicts with SetOf + univ.Choice.tagSet: ChoiceDecoder(), # conflicts with Any + # character string types + char.UTF8String.tagSet: UTF8StringDecoder(), + char.NumericString.tagSet: NumericStringDecoder(), + char.PrintableString.tagSet: PrintableStringDecoder(), + char.TeletexString.tagSet: TeletexStringDecoder(), + char.VideotexString.tagSet: VideotexStringDecoder(), + char.IA5String.tagSet: IA5StringDecoder(), + char.GraphicString.tagSet: GraphicStringDecoder(), + char.VisibleString.tagSet: VisibleStringDecoder(), + char.GeneralString.tagSet: GeneralStringDecoder(), + char.UniversalString.tagSet: UniversalStringDecoder(), + char.BMPString.tagSet: BMPStringDecoder(), + # useful types + useful.GeneralizedTime.tagSet: GeneralizedTimeDecoder(), + useful.UTCTime.tagSet: UTCTimeDecoder() + } + +# Type-to-codec map for ambiguous ASN.1 types +typeMap = { + univ.Set.typeId: SetDecoder(), + univ.SetOf.typeId: SetOfDecoder(), + univ.Sequence.typeId: SequenceDecoder(), + univ.SequenceOf.typeId: SequenceOfDecoder(), + univ.Choice.typeId: ChoiceDecoder(), + univ.Any.typeId: AnyDecoder() + } + +( stDecodeTag, stDecodeLength, stGetValueDecoder, stGetValueDecoderByAsn1Spec, + stGetValueDecoderByTag, stTryAsExplicitTag, stDecodeValue, + stDumpRawValue, stErrorCondition, stStop ) = [x for x in range(10)] + +class Decoder: + defaultErrorState = stErrorCondition +# defaultErrorState = stDumpRawValue + defaultRawDecoder = AnyDecoder() + def __init__(self, tagMap, typeMap={}): + self.__tagMap = tagMap + self.__typeMap = typeMap + self.__endOfOctetsTagSet = eoo.endOfOctets.getTagSet() + # Tag & TagSet objects caches + self.__tagCache = {} + self.__tagSetCache = {} + + def __call__(self, substrate, asn1Spec=None, tagSet=None, + length=None, state=stDecodeTag, recursiveFlag=1): + fullSubstrate = substrate + while state != stStop: + if state == stDecodeTag: + # Decode tag + if not substrate: + raise error.SubstrateUnderrunError( + 'Short octet stream on tag decoding' + ) + + firstOctet = substrate[0] + substrate = substrate[1:] + if firstOctet in self.__tagCache: + lastTag = self.__tagCache[firstOctet] + else: + t = oct2int(firstOctet) + tagClass = t&0xC0 + tagFormat = t&0x20 + tagId = t&0x1F + if tagId == 0x1F: + tagId = 0 + while 1: + if not substrate: + raise error.SubstrateUnderrunError( + 'Short octet stream on long tag decoding' + ) + t = oct2int(substrate[0]) + tagId = tagId << 7 | (t&0x7F) + substrate = substrate[1:] + if not t&0x80: + break + lastTag = tag.Tag( + tagClass=tagClass, tagFormat=tagFormat, tagId=tagId + ) + if tagId < 31: + # cache short tags + self.__tagCache[firstOctet] = lastTag + if tagSet is None: + if firstOctet in self.__tagSetCache: + tagSet = self.__tagSetCache[firstOctet] + else: + # base tag not recovered + tagSet = tag.TagSet((), lastTag) + if firstOctet in self.__tagCache: + self.__tagSetCache[firstOctet] = tagSet + else: + tagSet = lastTag + tagSet + state = stDecodeLength + if state == stDecodeLength: + # Decode length + if not substrate: + raise error.SubstrateUnderrunError( + 'Short octet stream on length decoding' + ) + firstOctet = oct2int(substrate[0]) + if firstOctet == 128: + size = 1 + length = -1 + elif firstOctet < 128: + length, size = firstOctet, 1 + else: + size = firstOctet & 0x7F + # encoded in size bytes + length = 0 + lengthString = substrate[1:size+1] + # missing check on maximum size, which shouldn't be a + # problem, we can handle more than is possible + if len(lengthString) != size: + raise error.SubstrateUnderrunError( + '%s<%s at %s' % + (size, len(lengthString), tagSet) + ) + for char in lengthString: + length = (length << 8) | oct2int(char) + size = size + 1 + state = stGetValueDecoder + substrate = substrate[size:] + if length != -1 and len(substrate) < length: + raise error.SubstrateUnderrunError( + '%d-octet short' % (length - len(substrate)) + ) + if state == stGetValueDecoder: + if asn1Spec is None: + state = stGetValueDecoderByTag + else: + state = stGetValueDecoderByAsn1Spec + # + # There're two ways of creating subtypes in ASN.1 what influences + # decoder operation. These methods are: + # 1) Either base types used in or no IMPLICIT tagging has been + # applied on subtyping. + # 2) Subtype syntax drops base type information (by means of + # IMPLICIT tagging. + # The first case allows for complete tag recovery from substrate + # while the second one requires original ASN.1 type spec for + # decoding. + # + # In either case a set of tags (tagSet) is coming from substrate + # in an incremental, tag-by-tag fashion (this is the case of + # EXPLICIT tag which is most basic). Outermost tag comes first + # from the wire. + # + if state == stGetValueDecoderByTag: + if tagSet in self.__tagMap: + concreteDecoder = self.__tagMap[tagSet] + else: + concreteDecoder = None + if concreteDecoder: + state = stDecodeValue + else: + _k = tagSet[:1] + if _k in self.__tagMap: + concreteDecoder = self.__tagMap[_k] + else: + concreteDecoder = None + if concreteDecoder: + state = stDecodeValue + else: + state = stTryAsExplicitTag + if state == stGetValueDecoderByAsn1Spec: + if isinstance(asn1Spec, (dict, tagmap.TagMap)): + if tagSet in asn1Spec: + __chosenSpec = asn1Spec[tagSet] + else: + __chosenSpec = None + else: + __chosenSpec = asn1Spec + if __chosenSpec is not None and ( + tagSet == __chosenSpec.getTagSet() or \ + tagSet in __chosenSpec.getTagMap() + ): + # use base type for codec lookup to recover untagged types + baseTagSet = __chosenSpec.baseTagSet + if __chosenSpec.typeId is not None and \ + __chosenSpec.typeId in self.__typeMap: + # ambiguous type + concreteDecoder = self.__typeMap[__chosenSpec.typeId] + elif baseTagSet in self.__tagMap: + # base type or tagged subtype + concreteDecoder = self.__tagMap[baseTagSet] + else: + concreteDecoder = None + if concreteDecoder: + asn1Spec = __chosenSpec + state = stDecodeValue + else: + state = stTryAsExplicitTag + elif tagSet == self.__endOfOctetsTagSet: + concreteDecoder = self.__tagMap[tagSet] + state = stDecodeValue + else: + state = stTryAsExplicitTag + if state == stTryAsExplicitTag: + if tagSet and \ + tagSet[0][1] == tag.tagFormatConstructed and \ + tagSet[0][0] != tag.tagClassUniversal: + # Assume explicit tagging + concreteDecoder = explicitTagDecoder + state = stDecodeValue + else: + state = self.defaultErrorState + if state == stDumpRawValue: + concreteDecoder = self.defaultRawDecoder + state = stDecodeValue + if state == stDecodeValue: + if recursiveFlag: + decodeFun = self + else: + decodeFun = None + if length == -1: # indef length + value, substrate = concreteDecoder.indefLenValueDecoder( + fullSubstrate, substrate, asn1Spec, tagSet, length, + stGetValueDecoder, decodeFun + ) + else: + value, _substrate = concreteDecoder.valueDecoder( + fullSubstrate, substrate, asn1Spec, tagSet, length, + stGetValueDecoder, decodeFun + ) + if recursiveFlag: + substrate = substrate[length:] + else: + substrate = _substrate + state = stStop + if state == stErrorCondition: + raise error.PyAsn1Error( + '%s not in asn1Spec: %s' % (tagSet, repr(asn1Spec)) + ) + return value, substrate + +decode = Decoder(tagMap, typeMap) + +# XXX +# non-recursive decoding; return position rather than substrate Property changes on: branches/ospace_0.5/server/lib/pyasn1/codec/ber/decoder.py ___________________________________________________________________ Added: svn:mime-type + text/plain Added: branches/ospace_0.5/server/lib/pyasn1/codec/ber/encoder.py =================================================================== --- branches/ospace_0.5/server/lib/pyasn1/codec/ber/encoder.py (rev 0) +++ branches/ospace_0.5/server/lib/pyasn1/codec/ber/encoder.py 2011-11-22 21:22:09 UTC (rev 321) @@ -0,0 +1,334 @@ +# BER encoder +from pyasn1.type import base, tag, univ, char, useful +from pyasn1.codec.ber import eoo +from pyasn1.compat.octets import int2oct, ints2octs, null, str2octs +from pyasn1 import error + +class Error(Exception): pass + +class AbstractItemEncoder: + supportIndefLenMode = 1 + def encodeTag(self, t, isConstructed): + tagClass, tagFormat, tagId = t.asTuple() # this is a hotspot + v = tagClass | tagFormat + if isConstructed: + v = v|tag.tagFormatConstructed + if tagId < 31: + return int2oct(v|tagId) + else: + s = int2oct(tagId&0x7f) + tagId = tagId >> 7 + while tagId: + s = int2oct(0x80|(tagId&0x7f)) + s + tagId = tagId >> 7 + return int2oct(v|0x1F) + s + + def encodeLength(self, length, defMode): + if not defMode and self.supportIndefLenMode: + return int2oct(0x80) + if length < 0x80: + return int2oct(length) + else: + substrate = null + while length: + substrate = int2oct(length&0xff) + substrate + length = length >> 8 + substrateLen = len(substrate) + if substrateLen > 126: + raise Error('Length octets overflow (%d)' % substrateLen) + return int2oct(0x80 | substrateLen) + substrate + + def encodeValue(self, encodeFun, value, defMode, maxChunkSize): + raise Error('Not implemented') + + def _encodeEndOfOctets(self, encodeFun, defMode): + if defMode or not self.supportIndefLenMode: + return null + else: + return encodeFun(eoo.endOfOctets, defMode) + + def encode(self, encodeFun, value, defMode, maxChunkSize): + substrate, isConstructed = self.encodeValue( + encodeFun, value, defMode, maxChunkSize + ) + tagSet = value.getTagSet() + if tagSet: + if not isConstructed: # primitive form implies definite mode + defMode = 1 + return self.encodeTag( + tagSet[-1], isConstructed + ) + self.encodeLength( + len(substrate), defMode + ) + substrate + self._encodeEndOfOctets(encodeFun, defMode) + else: + return substrate # untagged value + +class EndOfOctetsEncoder(AbstractItemEncoder): + def encodeValue(self, encodeFun, value, defMode, maxChunkSize): + return null, 0 + +class ExplicitlyTaggedItemEncoder(AbstractItemEncoder): + def encodeValue(self, encodeFun, value, defMode, maxChunkSize): + if isinstance(value, base.AbstractConstructedAsn1Item): + value = value.clone(tagSet=value.getTagSet()[:-1], + cloneValueFlag=1) + else: + value = value.clone(tagSet=value.getTagSet()[:-1]) + return encodeFun(value, defMode, maxChunkSize), 1 + +explicitlyTaggedItemEncoder = ExplicitlyTaggedItemEncoder() + +class IntegerEncoder(AbstractItemEncoder): + supportIndefLenMode = 0 + def encodeValue(self, encodeFun, value, defMode, maxChunkSize): + octets = [] + value = int(value) # to save on ops on asn1 type + while 1: + octets.insert(0, value & 0xff) + if value == 0 or value == -1: + break + value = value >> 8 + if value == 0 and octets[0] & 0x80: + octets.insert(0, 0) + while len(octets) > 1 and \ + (octets[0] == 0 and octets[1] & 0x80 == 0 or \ + octets[0] == 0xff and octets[1] & 0x80 != 0): + del octets[0] + return ints2octs(octets), 0 + +class BitStringEncoder(AbstractItemEncoder): + def encodeValue(self, encodeFun, value, defMode, maxChunkSize): + if not maxChunkSize or len(value) <= maxChunkSize*8: + r = {}; l = len(value); p = 0; j = 7 + while p < l: + i, j = divmod(p, 8) + r[i] = r.get(i,0) | value[p]<<(7-j) + p = p + 1 + keys = list(r); keys.sort() + return int2oct(7-j) + ints2octs([r[k] for k in keys]), 0 + else: + pos = 0; substrate = null + while 1: + # count in octets + v = value.clone(value[pos*8:pos*8+maxChunkSize*8]) + if not v: + break + substrate = substrate + encodeFun(v, defMode, maxChunkSize) + pos = pos + maxChunkSize + return substrate, 1 + +class OctetStringEncoder(AbstractItemEncoder): + def encodeValue(self, encodeFun, value, defMode, maxChunkSize): + if not maxChunkSize or len(value) <= maxChunkSize: + return value.asOctets(), 0 + else: + pos = 0; substrate = null + while 1: + v = value.clone(value[pos:pos+maxChunkSize]) + if not v: + break + substrate = substrate + encodeFun(v, defMode, maxChunkSize) + pos = pos + maxChunkSize + return substrate, 1 + +class NullEncoder(AbstractItemEncoder): + supportIndefLenMode = 0 + def encodeValue(self, encodeFun, value, defMode, maxChunkSize): + return null, 0 + +class ObjectIdentifierEncoder(AbstractItemEncoder): + supportIndefLenMode = 0 + precomputedValues = { + (1, 3, 6, 1, 2): (43, 6, 1, 2), + (1, 3, 6, 1, 4): (43, 6, 1, 4) + } + def encodeValue(self, encodeFun, value, defMode, maxChunkSize): + oid = value.asTuple() + if oid[:5] in self.precomputedValues: + octets = self.precomputedValues[oid[:5]] + index = 5 + else: + if len(oid) < 2: + raise error.PyAsn1Error('Short OID %s' % value) + + # Build the first twos + index = 0 + subid = oid[index] * 40 + subid = subid + oid[index+1] + if subid < 0 or subid > 0xff: + raise error.PyAsn1Error( + 'Initial sub-ID overflow %s in OID %s' % (oid[index:], value) + ) + octets = (subid,) + index = index + 2 + + # Cycle through subids + for subid in oid[index:]: + if subid > -1 and subid < 128: + # Optimize for the common case + octets = octets + (subid & 0x7f,) + elif subid < 0 or subid > 0xFFFFFFFF: + raise error.PyAsn1Error( + 'SubId overflow %s in %s' % (subid, value) + ) + else: + # Pack large Sub-Object IDs + res = (subid & 0x7f,) + subid = subid >> 7 + while subid > 0: + res = (0x80 | (subid & 0x7f),) + res + subid = subid >> 7 + # Add packed Sub-Object ID to resulted Object ID + octets += res + + return ints2octs(octets), 0 + +class RealEncoder(AbstractItemEncoder): + def encodeValue(self, encodeFun, value, defMode, maxChunkSize): + if value.isPlusInfinity(): + return int2oct(0x40), 0 + if value.isMinusInfinity(): + return int2oct(0x41), 0 + m, b, e = value + if not m: + return null, 0 + if b == 10: + return str2octs('\x03%dE%s%d' % (m, e == 0 and '+' or '', e)), 0 + elif b == 2: + fo = 0x80 # binary enoding + if m < 0: + fo = fo | 0x40 # sign bit + m = -m + while int(m) != m: # drop floating point + m *= 2 + e -= 1 + while m & 0x1 == 0: # mantissa normalization + m >>= 1 + e += 1 + eo = null + while e: + eo = int2oct(e&0xff) + eo + e >>= 8 + n = len(eo) + if n > 0xff: + raise error.PyAsn1Error('Real exponent overflow') + if n == 1: + pass + elif n == 2: + fo |= 1 + elif n == 3: + fo |= 2 + else: + fo |= 3 + eo = int2oct(n//0xff+1) + eo + po = null + while m: + po = int2oct(m&0xff) + po + m >>= 8 + substrate = int2oct(fo) + eo + po + return substrate, 0 + else: + raise error.PyAsn1Error('Prohibited Real base %s' % b) + +class SequenceEncoder(AbstractItemEncoder): + def encodeValue(self, encodeFun, value, defMode, maxChunkSize): + value.setDefaultComponents() + value.verifySizeSpec() + substrate = null; idx = len(value) + while idx > 0: + idx = idx - 1 + if value[idx] is None: # Optional component + continue + component = value.getDefaultComponentByPosition(idx) + if component is not None and component == value[idx]: + continue + substrate = encodeFun( + value[idx], defMode, maxChunkSize + ) + substrate + return substrate, 1 + +class SequenceOfEncoder(AbstractItemEncoder): + def encodeValue(self, encodeFun, value, defMode, maxChunkSize): + value.verifySizeSpec() + substrate = null; idx = len(value) + while idx > 0: + idx = idx - 1 + substrate = encodeFun( + value[idx], defMode, maxChunkSize + ) + substrate + return substrate, 1 + +class ChoiceEncoder(AbstractItemEncoder): + def encodeValue(self, encodeFun, value, defMode, maxChunkSize): + return encodeFun(value.getComponent(), defMode, maxChunkSize), 1 + +class AnyEncoder(OctetStringEncoder): + def encodeValue(self, encodeFun, value, defMode, maxChunkSize): + return value.asOctets(), defMode == 0 + +tagMap = { + eoo.endOfOctets.tagSet: EndOfOctetsEncoder(), + univ.Boolean.tagSet: IntegerEncoder(), + univ.Integer.tagSet: IntegerEncoder(), + univ.BitString.tagSet: BitStringEncoder(), + univ.OctetString.tagSet: OctetStringEncoder(), + univ.Null.tagSet: NullEncoder(), + univ.ObjectIdentifier.tagSet: ObjectIdentifierEncoder(), + univ.Enumerated.tagSet: IntegerEncoder(), + univ.Real.tagSet: RealEncoder(), + # Sequence & Set have same tags as SequenceOf & SetOf + univ.SequenceOf.tagSet: SequenceOfEncoder(), + univ.SetOf.tagSet: SequenceOfEncoder(), + univ.Choice.tagSet: ChoiceEncoder(), + # character string types + char.UTF8String.tagSet: OctetStringEncoder(), + char.NumericString.tagSet: OctetStringEncoder(), + char.PrintableString.tagSet: OctetStringEncoder(), + char.TeletexString.tagSet: OctetStringEncoder(), + char.VideotexString.tagSet: OctetStringEncoder(), + char.IA5String.tagSet: OctetStringEncoder(), + char.GraphicString.tagSet: OctetStringEncoder(), + char.VisibleString.tagSet: OctetStringEncoder(), + char.GeneralString.tagSet: OctetStringEncoder(), + char.UniversalString.tagSet: OctetStringEncoder(), + char.BMPString.tagSet: OctetStringEncoder(), + # useful types + useful.GeneralizedTime.tagSet: OctetStringEncoder(), + useful.UTCTime.tagSet: OctetStringEncoder() + } + +# Type-to-codec map for ambiguous ASN.1 types +typeMap = { + univ.Set.typeId: SequenceEncoder(), + univ.SetOf.typeId: SequenceOfEncoder(), + univ.Sequence.typeId: SequenceEncoder(), + univ.SequenceOf.typeId: SequenceOfEncoder(), + univ.Choice.typeId: ChoiceEncoder(), + univ.Any.typeId: AnyEncoder() + } + +class Encoder: + def __init__(self, tagMap, typeMap={}): + self.__tagMap = tagMap + self.__typeMap = typeMap + + def __call__(self, value, defMode=1, maxChunkSize=0): + tagSet = value.getTagSet() + if len(tagSet) > 1: + concreteEncoder = explicitlyTaggedItemEncoder + else: + if value.typeId is not None and value.typeId in self.__typeMap: + concreteEncoder = self.__typeMap[value.typeId] + elif tagSet in self.__tagMap: + concreteEncoder = self.__tagMap[tagSet] + else: + baseTagSet = value.baseTagSet + if baseTagSet in self.__tagMap: + concreteEncoder = self.__tagMap[baseTagSet] + else: + raise Error('No encoder for %s' % value) + return concreteEncoder.encode( + self, value, defMode, maxChunkSize + ) + +encode = Encoder(tagMap, typeMap) Property changes on: branches/ospace_0.5/server/lib/pyasn1/codec/ber/encoder.py ___________________________________________________________________ Added: svn:mime-type + text/plain Added: branches/ospace_0.5/server/lib/pyasn1/codec/ber/eoo.py =================================================================== --- branches/ospace_0.5/server/lib/pyasn1/codec/ber/eoo.py (rev 0) +++ branches/ospace_0.5/server/lib/pyasn1/codec/ber/eoo.py 2011-11-22 21:22:09 UTC (rev 321) @@ -0,0 +1,8 @@ +from pyasn1.type import base, tag + +class EndOfOctets(base.AbstractSimpleAsn1Item): + defaultValue = 0 + tagSet = tag.initTagSet( + tag.Tag(tag.tagClassUniversal, tag.tagFormatSimple, 0x00) + ) +endOfOctets = EndOfOctets() Property changes on: branches/ospace_0.5/server/lib/pyasn1/codec/ber/eoo.py ___________________________________________________________________ Added: svn:mime-type + text/plain Property changes on: branches/ospace_0.5/server/lib/pyasn1/codec/cer/__init__.py ___________________________________________________________________ Added: svn:mime-type + text/plain Added: branches/ospace_0.5/server/lib/pyasn1/codec/cer/decoder.py =================================================================== --- branches/ospace_0.5/server/lib/pyasn1/codec/cer/decoder.py (rev 0) +++ branches/ospace_0.5/server/lib/pyasn1/codec/cer/decoder.py 2011-11-22 21:22:09 UTC (rev 321) @@ -0,0 +1,32 @@ +# CER decoder +from pyasn1.type import univ +from pyasn1.codec.ber import decoder +from pyasn1.compat.octets import oct2int +from pyasn1 import error + +class BooleanDecoder(decoder.AbstractSimpleDecoder): + protoComponent = univ.Boolean(0) + def valueDecoder(self, fullSubstrate, substrate, asn1Spec, tagSet, length, + state, decodeFun): + substrate = substrate[:length] + if not substrate: + raise error.PyAsn1Error('Empty substrate') + byte = oct2int(substrate[0]) + if byte == 0xff: + value = 1 + elif byte == 0x00: + value = 0 + else: + raise error.PyAsn1Error('Boolean CER violation: %s' % byte) + return self._createComponent(asn1Spec, tagSet, value), substrate[1:] + +tagMap = decoder.tagMap.copy() +tagMap.update({ + univ.Boolean.tagSet: BooleanDecoder(), + }) + +typeMap = decoder.typeMap + +class Decoder(decoder.Decoder): pass + +decode = Decoder(tagMap, decoder.typeMap) Property changes on: branches/ospace_0.5/server/lib/pyasn1/codec/cer/decoder.py ___________________________________________________________________ Added: svn:mime-type + text/plain Added: branches/ospace_0.5/server/lib/pyasn1/codec/cer/encoder.py =================================================================== --- branches/ospace_0.5/server/lib/pyasn1/codec/cer/encoder.py (rev 0) +++ branches/ospace_0.5/server/lib/pyasn1/codec/cer/encoder.py 2011-11-22 21:22:09 UTC (rev 321) @@ -0,0 +1,87 @@ +# CER encoder +from pyasn1.type import univ +from pyasn1.codec.ber import encoder +from pyasn1.compat.octets import int2oct, null + +class BooleanEncoder(encoder.IntegerEncoder): + def encodeValue(self, encodeFun, client, defMode, maxChunkSize): + if client == 0: + substrate = int2oct(0) + else: + substrate = int2oct(255) + return substrate, 0 + +class BitStringEncoder(encoder.BitStringEncoder): + def encodeValue(self, encodeFun, client, defMode, maxChunkSize): + return encoder.BitStringEncoder.encodeValue( + self, encodeFun, client, defMode, 1000 + ) + +class OctetStringEncoder(encoder.OctetStringEncoder): + def encodeValue(self, encodeFun, client, defMode, maxChunkSize): + return encoder.OctetStringEncoder.encodeValue( + self, encodeFun, client, defMode, 1000 + ) + +# specialized RealEncoder here +# specialized GeneralStringEncoder here +# specialized GeneralizedTimeEncoder here +# specialized UTCTimeEncoder here + +class SetOfEncoder(encoder.SequenceOfEncoder): + def encodeValue(self, encodeFun, client, defMode, maxChunkSize): + if isinstance(client, univ.SequenceAndSetBase): + client.setDefaultComponents() + client.verifySizeSpec() + substrate = null; idx = len(client) + # This is certainly a hack but how else do I distinguish SetOf + # from Set if they have the same tags&constraints? + if isinstance(client, univ.SequenceAndSetBase): + # Set + comps = [] + while idx > 0: + idx = idx - 1 + if client[idx] is None: # Optional component + continue + if client.getDefaultComponentByPosition(idx) == client[idx]: + continue + comps.append(client[idx]) + comps.sort(key=lambda x: isinstance(x, univ.Choice) and \ + x.getMinTagSet() or x.getTagSet()) + for c in comps: + substrate += encodeFun(c, defMode, maxChunkSize) + else: + # SetOf + compSubs = [] + while idx > 0: + idx = idx - 1 + compSubs.append( + encodeFun(client[idx], defMode, maxChunkSize) + ) + compSubs.sort() # perhaps padding's not needed + substrate = null + for compSub in compSubs: + substrate += compSub + return substrate, 1 + +tagMap = encoder.tagMap.copy() +tagMap.update({ + univ.Boolean.tagSet: BooleanEncoder(), + univ.BitString.tagSet: BitStringEncoder(), + univ.OctetString.tagSet: OctetStringEncoder(), + univ.SetOf().tagSet: SetOfEncoder() # conflcts with Set + }) + +typeMap = encoder.typeMap.copy() +typeMap.update({ + univ.Set.typeId: SetOfEncoder(), + univ.SetOf.typeId: SetOfEncoder() + }) + +class Encoder(encoder.Encoder): + def __call__(self, client, defMode=0, maxChunkSize=0): + return encoder.Encoder.__call__(self, client, defMode, maxChunkSize) + +encode = Encoder(tagMap, typeMap) + +# EncoderFactory queries class instance and builds a map of tags -> encoders Property changes on: branches/ospace_0.5/server/lib/pyasn1/codec/cer/encoder.py ___________________________________________________________________ Added: svn:mime-type + text/plain Property changes on: branches/ospace_0.5/server/lib/pyasn1/codec/der/__init__.py ___________________________________________________________________ Added: svn:mime-type + text/plain Added: branches/ospace_0.5/server/lib/pyasn1/codec/der/decoder.py =================================================================== --- branches/ospace_0.5/server/lib/pyasn1/codec/der/decoder.py (rev 0) +++ branches/ospace_0.5/server/lib/pyasn1/codec/der/decoder.py 2011-11-22 21:22:09 UTC (rev 321) @@ -0,0 +1,5 @@ +# DER decoder +from pyasn1.type import univ +from pyasn1.codec.cer import decoder + +decode = decoder.Decoder(decoder.tagMap, decoder.typeMap) Property changes on: branches/ospace_0.5/server/lib/pyasn1/codec/der/decoder.py ___________________________________________________________________ Added: svn:mime-type + text/plain Added: branches/ospace_0.5/server/lib/pyasn1/codec/der/encoder.py =================================================================== --- branches/ospace_0.5/server/lib/pyasn1/codec/der/encoder.py (rev 0) +++ branches/ospace_0.5/server/lib/pyasn1/codec/der/encoder.py 2011-11-22 21:22:09 UTC (rev 321) @@ -0,0 +1,28 @@ +# DER encoder +from pyasn1.type import univ +from pyasn1.codec.cer import encoder + +class SetOfEncoder(encoder.SetOfEncoder): + def _cmpSetComponents(self, c1, c2): + tagSet1 = isinstance(c1, univ.Choice) and \ + c1.getEffectiveTagSet() or c1.getTagSet() + tagSet2 = isinstance(c2, univ.Choice) and \ + c2.getEffectiveTagSet() or c2.getTagSet() + return cmp(tagSet1, tagSet2) + +tagMap = encoder.... [truncated message content] |
From: <qa...@us...> - 2011-11-15 07:50:58
|
Revision: 320 http://ospace.svn.sourceforge.net/ospace/?rev=320&view=rev Author: qark Date: 2011-11-15 07:50:47 +0000 (Tue, 15 Nov 2011) Log Message: ----------- - MD5 authentication is now backward compatible. [Qark] Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/client-pygame/res/cs/LC_MESSAGES/OSPACE.mo branches/ospace_0.5/client-pygame/res/cs/LC_MESSAGES/OSPACE.po branches/ospace_0.5/server/lib/ige/Authentication.py Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2011-11-14 21:13:14 UTC (rev 319) +++ branches/ospace_0.5/ChangeLog.txt 2011-11-15 07:50:47 UTC (rev 320) @@ -6,6 +6,9 @@ - $Author$ - $Revision$ +[2011-11-15] +- MD5 authentication is now backward compatible. [Qark] + [2011-11-14] - Fixed AI scripts deployment issues. [Qark] - Added support for different authentication schemes. Supported are PLAIN, MD5 (default), and SHA256. [Qark] Modified: branches/ospace_0.5/client-pygame/res/cs/LC_MESSAGES/OSPACE.mo =================================================================== (Binary files differ) Modified: branches/ospace_0.5/client-pygame/res/cs/LC_MESSAGES/OSPACE.po =================================================================== --- branches/ospace_0.5/client-pygame/res/cs/LC_MESSAGES/OSPACE.po 2011-11-14 21:13:14 UTC (rev 319) +++ branches/ospace_0.5/client-pygame/res/cs/LC_MESSAGES/OSPACE.po 2011-11-15 07:50:47 UTC (rev 320) @@ -1,86 +1,753 @@ msgid "" msgstr "" "Project-Id-Version: Outer Space 0.5\n" -"POT-Creation-Date: \n" -"PO-Revision-Date: 2007-07-19 11:11+0100\n" -"Last-Translator: PeS <pe...@sa...>\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-09-15 18:47+0100\n" +"PO-Revision-Date: 2010-09-15 18:53+0100\n" +"Last-Translator: Qark <qa...@os...>\n" "Language-Team: IGE <qa...@se...>\n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Poedit-Language: Czech\n" "X-Poedit-Basepath: ../../..\n" "X-Poedit-KeywordsList: N_\n" "X-Poedit-SearchPath-0: lib\n" +#: lib/osci/gdata.py:36 +msgid "Asteroid" +msgstr "Asteroid" + +#: lib/osci/gdata.py:37 +msgid "Gas Giant" +msgstr "Plynný obr" + +#: lib/osci/gdata.py:38 +msgid "Rock" +msgstr "Skalnatá" + +#: lib/osci/gdata.py:39 +msgid "Cold" +msgstr "Ledová" + +#: lib/osci/gdata.py:40 +msgid "Desert" +msgstr "Pouštní" + +#: lib/osci/gdata.py:41 +msgid "Hostile" +msgstr "Nepříznivá" + +#: lib/osci/gdata.py:42 +msgid "Marginal" +msgstr "Neúrodná" + +#: lib/osci/gdata.py:43 +msgid "Terrestrial" +msgstr "Pozemská" + +#: lib/osci/gdata.py:44 +msgid "Gaia" +msgstr "Gaia" + +#: lib/osci/gdata.py:45 +msgid "Unknown" +msgstr "Neznámý" + +#: lib/osci/gdata.py:49 +msgid "Super giant" +msgstr "Veleobr" + +#: lib/osci/gdata.py:50 +msgid "Giant" +msgstr "Obr" + +#: lib/osci/gdata.py:51 +msgid "Main sequence" +msgstr "Hlavní sekvence" + +#: lib/osci/gdata.py:52 +msgid "Dwarf" +msgstr "Trpaslík" + +#: lib/osci/gdata.py:53 +msgid "Black hole" +msgstr "Černá díra" + +#: lib/osci/gdata.py:54 +msgid "Neutron star" +msgstr "Neutronová hvězda" + +#: lib/osci/gdata.py:55 +msgid "Worm hole" +msgstr "Červí díra" + +#: lib/osci/gdata.py:59 +msgid "small" +msgstr "malá" + +#: lib/osci/gdata.py:60 +msgid "medium" +msgstr "střední" + +#: lib/osci/gdata.py:61 +msgid "large" +msgstr "velká" + +#: lib/osci/gdata.py:62 +msgid "planet" +msgstr "planeta" + +#: lib/osci/gdata.py:66 +#: lib/osci/gdata.py:78 +msgid "None" +msgstr "Žádný" + +#: lib/osci/gdata.py:67 +msgid "Move to" +msgstr "Přesun" + +#: lib/osci/gdata.py:68 +msgid "Declare War at" +msgstr "Vyhlaš válku" + +#: lib/osci/gdata.py:69 +msgid "Deploy Ship" +msgstr "Rozlož loď" + +#: lib/osci/gdata.py:70 +msgid "Redirect to" +msgstr "Přesměrovat do" + +#: lib/osci/gdata.py:71 +msgid "Refuel at" +msgstr "Natankuj na" + +#: lib/osci/gdata.py:72 +msgid "Repeat from" +msgstr "Opakovat od" + +#: lib/osci/gdata.py:73 +msgid "Wait" +msgstr "Čekat" + +#: lib/osci/gdata.py:74 +msgid "Enter Wormhole at" +msgstr "Vstup do červí díry v" + +#: lib/osci/gdata.py:79 +msgid "Uranium" +msgstr "Uran" + +#: lib/osci/gdata.py:80 +msgid "Titanium" +msgstr "Titan" + +#: lib/osci/gdata.py:81 +msgid "Chromium" +msgstr "Chrom" + +#: lib/osci/gdata.py:82 +msgid "Silicium" +msgstr "Silicium" + +#: lib/osci/gdata.py:83 +msgid "Carboneum" +msgstr "Carboneum" + +#: lib/osci/gdata.py:84 +msgid "Antimatter" +msgstr "Antihmota" + +#: lib/osci/gdata.py:85 +msgid "Plutonium" +msgstr "Plutonium" + +#: lib/osci/gdata.py:86 +msgid "Wolframium" +msgstr "Wolframium" + +#: lib/osci/gdata.py:87 +msgid "Mutagen" +msgstr "Mutagen" + +#: lib/osci/gdata.py:88 +msgid "Unnilseptium" +msgstr "Unnilseptium" + +#: lib/osci/gdata.py:91 +msgid "Enemy" +msgstr "Nepřítel" + +#: lib/osci/gdata.py:91 +msgid "Unfriendly" +msgstr "Nepřátelský" + +#: lib/osci/gdata.py:91 +#: lib/osci/gdata.py:92 +msgid "Neutral" +msgstr "Neutrální" + +#: lib/osci/gdata.py:92 +msgid "Friendly" +msgstr "Přítel" + +#: lib/osci/gdata.py:92 +msgid "Allied" +msgstr "Spojenec" + +#: lib/osci/gdata.py:95 +msgid "Passage for civilian ships" +msgstr "Přelet pro civilní lodě" + +#: lib/osci/gdata.py:96 +msgid "Passage for military ships" +msgstr "Přelet pro válečné lodě" + +#: lib/osci/gdata.py:97 +msgid "Permission to tank ships" +msgstr "Povolení doplňovat palivo pro lodě" + +#: lib/osci/gdata.py:98 +msgid "Limited trade agreement" +msgstr "Omezený obchodní pakt" + +#: lib/osci/gdata.py:99 +msgid "Unlimited trade agreement" +msgstr "Neomezený obchodní pakt" + +#: lib/osci/gdata.py:100 +msgid "Scanner map exchange" +msgstr "Výměna hvězdných map ze skeneru" + +#: lib/osci/gdata.py:101 +msgid "Research information exchange" +msgstr "Výměna informací z výzkumu" + +#: lib/osci/gdata.py:102 +msgid "Research cooperation" +msgstr "Spolupráce při výzkumu" + +#: lib/osci/gdata.py:116 +#: lib/osci/gdata.py:165 +msgid "Disabled" +msgstr "Vypnuto" + +#: lib/osci/gdata.py:116 +msgid "Enabled" +msgstr "Zapnuto" + +#: lib/osci/gdata.py:116 +msgid "Active" +msgstr "Aktivní" + +#: lib/osci/gdata.py:119 +msgid "Mailbox" +msgstr "Schránka" + +#: lib/osci/gdata.py:120 +msgid "Sent" +msgstr "Odesláno" + +#: lib/osci/gdata.py:121 +msgid "Events" +msgstr "Události" + +#: lib/osci/gdata.py:122 +#: lib/osci/gdata.py:128 +msgid "News" +msgstr "Novinky" + +#: lib/osci/gdata.py:123 +msgid "Questions" +msgstr "Otázky" + +#: lib/osci/gdata.py:124 +msgid "Issues" +msgstr "Chyby" + +#: lib/osci/gdata.py:125 +msgid "Suggestions" +msgstr "Návrhy" + +#: lib/osci/gdata.py:126 +#: lib/osci/gdata.py:127 +msgid "Public" +msgstr "Veřejný kanál" + +#: lib/osci/gdata.py:140 +#: lib/osci/gdata.py:141 +#: lib/osci/gdata.py:142 +msgid "MORALE IS TERRIBLE" +msgstr "MORÁLKA JE HROZNÁ" + +#: lib/osci/gdata.py:143 +msgid "MORALE IS BAD" +msgstr "MORÁLKA JE ŠPATNÁ" + +#: lib/osci/gdata.py:144 +msgid "MORALE IS VERY LOW" +msgstr "MORÁLKA JE VELMI NÍZKÁ" + +#: lib/osci/gdata.py:145 +msgid "MORALE IS LOW" +msgstr "MORÁLKA JE NÍZKÁ" + +#: lib/osci/gdata.py:146 +msgid "MORALE IS BELOW AVERAGE" +msgstr "MORÁLKA JE PODPRŮMĚRNÁ" + +#: lib/osci/gdata.py:147 +msgid " " +msgstr " " + +#: lib/osci/gdata.py:148 +msgid "MORALE IS HIGH" +msgstr "MORÁLKA JE VYSOKÁ" + +#: lib/osci/gdata.py:149 +msgid "MORALE IS SUPERB" +msgstr "MORÁLKA JE VÝBORNÁ" + +#: lib/osci/gdata.py:161 +msgid "Critical" +msgstr "Kritická" + +#: lib/osci/gdata.py:162 +msgid "Major" +msgstr "Velká" + +#: lib/osci/gdata.py:163 +msgid "Minor" +msgstr "Malá" + +#: lib/osci/gdata.py:164 +msgid "Info" +msgstr "Informace" + +#: lib/osci/StarMapWidget.py:121 +msgid "Select object" +msgstr "Vyber objekt" + +#: lib/osci/StarMapWidget.py:382 +#: lib/osci/StarMapWidget.py:1581 +#, python-format +msgid "System: %s [ID: %d]" +msgstr "Soustava: %s [ID: %d]" + +#: lib/osci/StarMapWidget.py:383 +#: lib/osci/StarMapWidget.py:414 +#: lib/osci/StarMapWidget.py:506 +#: lib/osci/StarMapWidget.py:617 +#, python-format +msgid "Coordinates: [%.2f, %.2f]" +msgstr "Souřadnice: [%.2f, %.2f]" + +#: lib/osci/StarMapWidget.py:384 +#: lib/osci/StarMapWidget.py:469 +#: lib/osci/StarMapWidget.py:505 +#: lib/osci/StarMapWidget.py:527 +#: lib/osci/StarMapWidget.py:615 +#, python-format +msgid "Scan pwr: %d" +msgstr "Síla senzorů: %d" + +#: lib/osci/StarMapWidget.py:385 +#, python-format +msgid "Star Class: %s" +msgstr "Třída hvězdy : %s" + +#: lib/osci/StarMapWidget.py:386 +#, python-format +msgid "Star Type: %s" +msgstr "Typ hvězdy: %s" + +#: lib/osci/StarMapWidget.py:388 +#: lib/osci/StarMapWidget.py:474 +#, python-format +msgid "Fame to Colonize: %d" +msgstr "" + +#: lib/osci/StarMapWidget.py:390 +#, python-format +msgid "Refuel: %d %%/turn [%d %% max]" +msgstr "Tankování: %d %%/tah [%d %% max]" + +#: lib/osci/StarMapWidget.py:392 +#, python-format +msgid "Repair ratio: %d %%/turn" +msgstr "Rychlost oprav: %d %%/tah" + +#: lib/osci/StarMapWidget.py:394 +#, python-format +msgid "Upgrade points: %d/turn" +msgstr "Modernizační body: %d/tah" + +#: lib/osci/StarMapWidget.py:396 +#, python-format +msgid "Fleet speed: +%d %%" +msgstr "Rychlost flotily: +%d %%" + +#: lib/osci/StarMapWidget.py:398 +#: lib/osci/StarMapWidget.py:426 +#, python-format +msgid "Pirate get fame chance: %d %%" +msgstr "Šance piráta získat slávu: %d %%" + +#: lib/osci/StarMapWidget.py:413 +#: lib/osci/StarMapWidget.py:1584 +#, python-format +msgid "Worm hole: %s [ID: %d]" +msgstr "Červí díra: %s [ID: %d]" + +#: lib/osci/StarMapWidget.py:419 +#, python-format +msgid "Destination: %s [ID: %d]" +msgstr "Cíl: %s [ID: %d]" + +#: lib/osci/StarMapWidget.py:420 +#, python-format +msgid "Dest. Coords: [%.2f, %.2f]" +msgstr "Souř. cíle: [%.2f, %.2f]" + +#: lib/osci/StarMapWidget.py:423 +msgid "Destination: ? [ID: ?]" +msgstr "Cíl: ? [ID: ?]" + +#: lib/osci/StarMapWidget.py:424 +msgid "Dest. Coords: [?, ?]" +msgstr "Cíl. souřadnice: [?, ?]" + +#: lib/osci/StarMapWidget.py:468 +#: lib/osci/StarMapWidget.py:1587 +#, python-format +msgid "Planet: %s [ID: %d]" +msgstr "Planeta: %s [ID: %d]" + +#: lib/osci/StarMapWidget.py:470 +#: lib/osci/StarMapWidget.py:616 +#, python-format +msgid "Scanner pwr: %d" +msgstr "Síla skeneru: %d" + +#: lib/osci/StarMapWidget.py:472 +#, python-format +msgid "Type: %s" +msgstr "Typ: %s" + +#: lib/osci/StarMapWidget.py:475 +#, python-format +msgid "Environment: %d" +msgstr "Životní prostř.: %d" + +#: lib/osci/StarMapWidget.py:476 +#, python-format +msgid "Minerals: %d" +msgstr "Minerály: %d" + +#: lib/osci/StarMapWidget.py:477 +#, python-format +msgid "Energy: %d" +msgstr "Energie: %d" + +#: lib/osci/StarMapWidget.py:478 +#, python-format +msgid "Slots: %d" +msgstr "slotů: %d" + +#: lib/osci/StarMapWidget.py:480 +#, python-format +msgid "Strat. resource: %s" +msgstr "Strategický zdroj: %s" + +#: lib/osci/StarMapWidget.py:483 +#: lib/osci/StarMapWidget.py:515 +#: lib/osci/StarMapWidget.py:633 +#, python-format +msgid "Owner: %s [ID: %s]" +msgstr "Vlastník: %s [ID: %s]" + +#: lib/osci/StarMapWidget.py:504 +#: lib/osci/StarMapWidget.py:1596 +#, python-format +msgid "Asteroid: %s [ID: %d]" +msgstr "Asteroid: %s [ID: %d]" + +#: lib/osci/StarMapWidget.py:507 +#: lib/osci/StarMapWidget.py:618 +#, python-format +msgid "Signature: %d" +msgstr "Signatura: %d" + +#: lib/osci/StarMapWidget.py:508 +#, python-format +msgid "Diameter: %d" +msgstr "Průměr: %d" + +#: lib/osci/StarMapWidget.py:509 +#, python-format +msgid "HP: %d" +msgstr "HP: %d" + +#: lib/osci/StarMapWidget.py:510 +#, python-format +msgid "Speed: %.2f" +msgstr "Rychlost: %.2f" + +#: lib/osci/StarMapWidget.py:512 +#: lib/osci/StarMapWidget.py:630 +#, python-format +msgid "ETA: %s" +msgstr "ETA: %s" + +#: lib/osci/StarMapWidget.py:525 +#: lib/osci/StarMapWidget.py:1598 +#, python-format +msgid "Unknown object [ID: %d]" +msgstr "Neznámý objekt [ID: %d]" + +#: lib/osci/StarMapWidget.py:614 +#: lib/osci/StarMapWidget.py:1593 +#, python-format +msgid "Fleet: %s [ID: %d]" +msgstr "Flotila: %s [ID: %d]" + +#: lib/osci/StarMapWidget.py:619 +#, fuzzy, python-format +msgid "Speed: %3.2f" +msgstr "Rychlost: %.2f" + +#: lib/osci/StarMapWidget.py:624 +#, fuzzy, python-format +msgid "Speed: <%3.2f – %3.2f>" +msgstr "Rychlost: %.2f" + +#: lib/osci/StarMapWidget.py:628 +#, fuzzy, python-format +msgid "Speed: <%3.2f – ∞>" +msgstr "Rychlost: %.2f" + +#: lib/osci/StarMapWidget.py:640 +#, python-format +msgid "Tanks: %d / %d [%d %%]" +msgstr "Nádrže: %d / %d [%d %%]" + +#: lib/osci/StarMapWidget.py:641 +#, python-format +msgid "Support (fuel): %d/turn" +msgstr "Podpora (palivo): %d/tah" + +#: lib/osci/StarMapWidget.py:642 +#, python-format +msgid "Support (const. pts): %d/turn" +msgstr "Podpora (konst. body): %d/tah" + +#: lib/osci/StarMapWidget.py:644 +#, python-format +msgid "Military power: %d" +msgstr "Vojenská síla: %d" + +#: lib/osci/StarMapWidget.py:651 +#, python-format +msgid "Operational time: %s" +msgstr "Provozní čas: %s" + +#: lib/osci/StarMapWidget.py:656 +#, python-format +msgid "Target: %s" +msgstr "Cíl: %s" + +#: lib/osci/StarMapWidget.py:659 +#: lib/osci/StarMapWidget.py:679 +msgid "Ships:" +msgstr "Lodě:" + +#: lib/osci/StarMapWidget.py:672 +#, python-format +msgid " %d x %s [%d, %d, %d, %d, %d]" +msgstr " %d x %s [%d, %d, %d, %d, %d]" + +#: lib/osci/StarMapWidget.py:682 +msgid "military" +msgstr "vojenská" + +#: lib/osci/StarMapWidget.py:684 +msgid "civilian" +msgstr "civilní" + +#: lib/osci/StarMapWidget.py:685 +#, python-format +msgid " %d x %s [%s %s ship]" +msgstr " %d x %s [%s %s loď]" + +#: lib/osci/StarMapWidget.py:697 +#, python-format +msgid "Command: %s %s" +msgstr "Příkaz: %s %s" + +#: lib/osci/StarMapWidget.py:1304 +msgid "Overlay Mode: " +msgstr "Překrytí mapy: " + +#: lib/osci/StarMapWidget.py:1306 +msgid "Normal" +msgstr "Normální" + +#: lib/osci/StarMapWidget.py:1308 +msgid "Diplomatic" +msgstr "Diplomacie" + +#: lib/osci/StarMapWidget.py:1310 +msgid "Environment" +msgstr "Prostředí" + +#: lib/osci/StarMapWidget.py:1312 +msgid "Pirate Fame" +msgstr "Pověst pirátů" + +#: lib/osci/StarMapWidget.py:1314 +msgid "Minerals" +msgstr "Minerály" + +#: lib/osci/StarMapWidget.py:1316 +msgid "Slots" +msgstr "Sloty" + +#: lib/osci/StarMapWidget.py:1318 +msgid "Fleet Acceleration" +msgstr "Zrychlení flotily" + +#: lib/osci/StarMapWidget.py:1320 +msgid "Refuel and Repair" +msgstr "Tankování a opravy" + +#: lib/osci/StarMapWidget.py:1322 +msgid "Morale" +msgstr "Morálka" + +#: lib/osci/StarMapWidget.py:1404 +msgid "Player Zones (CTRL-P)" +msgstr "" + +#: lib/osci/StarMapWidget.py:1405 +msgid "Civilian Ships (CTRL-H)" +msgstr "" + +#: lib/osci/StarMapWidget.py:1406 +#, fuzzy +msgid "Fleet Lines (CTRL-L)" +msgstr "Flotily" + +#: lib/osci/StarMapWidget.py:1407 +msgid "Redirect Arrows (CTRL-R)" +msgstr "" + +#: lib/osci/StarMapWidget.py:1408 +#, fuzzy +msgid "Scanners (CTRL-S)" +msgstr "Sdílení skeneru" + +#: lib/osci/StarMapWidget.py:1409 +msgid "Grid (CTRL-G)" +msgstr "" + +#: lib/osci/StarMapWidget.py:1411 +msgid "Alternate View (CTRL-A)" +msgstr "" + +#: lib/osci/StarMapWidget.py:1412 +#, fuzzy +msgid "Overlay: Diplomacy" +msgstr "Diplomacie" + +#: lib/osci/StarMapWidget.py:1413 +#, fuzzy +msgid "Overlay: Minerals" +msgstr "Překrytí mapy: " + +#: lib/osci/StarMapWidget.py:1414 +#, fuzzy +msgid "Overlay: Environment" +msgstr "Prostředí" + +#: lib/osci/StarMapWidget.py:1415 +#, fuzzy +msgid "Overlay: Slots" +msgstr "Překrytí mapy: " + +#: lib/osci/StarMapWidget.py:1416 +#, fuzzy +msgid "Overlay: Morale" +msgstr "Překrytí mapy: " + +#: lib/osci/StarMapWidget.py:1417 +#, fuzzy +msgid "Overlay: Fuel and Repair" +msgstr "Tankování a opravy" + +#: lib/osci/StarMapWidget.py:1418 +msgid "Overlay: Star Gate Speed" +msgstr "" + +#: lib/osci/StarMapWidget.py:1419 +#, fuzzy +msgid "Overlay: Pirate Fame" +msgstr "Pověst pirátů" + +#: lib/osci/StarMapWidget.py:1605 +#, python-format +msgid "Buoy on system: %s [ID: %d]" +msgstr "Bójka na soustavě: %s [ID: %d]" + +#: lib/osci/StarMapWidget.py:1608 +#, python-format +msgid "Buoy on worm hole: %s [ID: %d]" +msgstr "Bójka na červí díře: %s [ID: %d]" + +#: lib/osci/StarMapWidget.py:1610 +#, python-format +msgid "Buoy on unknown object [ID: %d]" +msgstr "Bójka na neznámém objektu [ID: %d]" + +#: lib/osci/StarMapWidget.py:1707 +msgid "Select object to hotkey. ESC to cancel." +msgstr "" + +#: lib/osci/StarMapWidget.py:1719 +#: lib/osci/StarMapWidget.py:1786 +#: lib/osci/dialog/FleetsAnalysisDlg.py:45 +msgid "Ready." +msgstr "Připraven." + #: lib/osci/handler.py:59 msgid "Updating OSCI database..." msgstr "Aktualizuji databázi..." -#: lib/osci/res.py:53 -msgid "Loading resources" -msgstr "Inicializuji klienta" +#: lib/osci/main.py:95 +msgid "Server sponsored by:" +msgstr "Server sponzorován" -#: lib/osci/res.py:60 -#: lib/osci/res.py:75 -#: lib/osci/res.py:91 -#: lib/osci/res.py:100 -#: lib/osci/res.py:109 -#: lib/osci/res.py:118 -msgid "Loading resources..." -msgstr "Nahrávám..." +#: lib/osci/main.py:99 +#: lib/osci/main.py:233 +#, fuzzy, python-format +msgid "Outer Space %s" +msgstr "Outer Space" -#: lib/osci/res.py:146 -#: lib/osci/dialog/StarSystemDlg.py:618 -msgid "[Unknown]" -msgstr "[Neznámý]" +#: lib/osci/main.py:102 +#, python-format +msgid "Pygame %s" +msgstr "Pygame %s" -#: lib/osci/res.py:149 -#: lib/osci/messages.py:229 -#: lib/osci/sequip.py:120 -#: lib/osci/dialog/NewTaskDlg.py:123 -#: lib/osci/dialog/NewTaskDlg.py:159 -#: lib/osci/dialog/EventsDlg.py:70 -#: lib/osci/dialog/ResearchDlg.py:86 -#: lib/osci/dialog/ResearchDlg.py:177 -#: lib/osci/dialog/FleetDlg.py:107 -#: lib/osci/dialog/ConstructionDlg.py:198 -#: lib/osci/dialog/ConstructionDlg.py:202 -#: lib/osci/dialog/ConstructionDlg.py:218 -#: lib/osci/dialog/ConstructionDlg.py:220 -#: lib/osci/dialog/ConstructionDlg.py:221 -#: lib/osci/dialog/ConstructionDlg.py:222 -#: lib/osci/dialog/ConstructionDlg.py:223 -#: lib/osci/dialog/ConstructionDlg.py:224 -#: lib/osci/dialog/ConstructionDlg.py:225 -#: lib/osci/dialog/ConstructionDlg.py:226 -#: lib/osci/dialog/ConstructionDlg.py:227 -#: lib/osci/dialog/ConstructionDlg.py:228 -#: lib/osci/dialog/ConstructionDlg.py:229 -#: lib/osci/dialog/ConstructionDlg.py:230 -#: lib/osci/dialog/ConstructionDlg.py:231 -#: lib/osci/dialog/ConstructionDlg.py:232 -#: lib/osci/dialog/ConstructionDlg.py:233 -#: lib/osci/dialog/ConstructionDlg.py:234 -#: lib/osci/dialog/ConstructionDlg.py:235 -#: lib/osci/dialog/FleetCommandDlg.py:145 -#: lib/osci/dialog/FleetCommandDlg.py:147 -#: lib/osci/dialog/StructTaskDlg.py:140 -#: lib/osci/dialog/DiplomacyDlg.py:170 -#: lib/osci/dialog/DiplomacyDlg.py:184 -#: lib/osci/dialog/PlanetsOverviewDlg.py:137 -#: lib/osci/dialog/PlanetsOverviewDlg.py:139 -#: lib/osci/dialog/StarSystemDlg.py:254 -#: lib/osci/dialog/StarSystemDlg.py:651 -#: lib/osci/dialog/StarSystemDlg.py:668 -#: lib/osci/dialog/StarSystemDlg.py:669 -#: lib/osci/dialog/StarSystemDlg.py:670 -#: lib/osci/dialog/StarSystemDlg.py:678 -#: lib/osci/dialog/StarSystemDlg.py:679 -#: lib/osci/dialog/StarSystemDlg.py:712 -msgid "N/A" -msgstr "N/A" +#: lib/osci/main.py:105 +#, python-format +msgid "Python %s" +msgstr "Python %s" +#: lib/osci/main.py:110 +#, python-format +msgid "Video Driver: %s [%dx%dx%d]" +msgstr "Video ovladač: %s [%dx%dx%d]" + #: lib/osci/messages.py:48 #, python-format msgid " (%s)" @@ -457,41 +1124,84 @@ "Výjimka: %s: %s\n" "Formát: %s" -#: lib/osci/messages.py:231 -#: lib/osci/messages.py:238 -#: lib/osci/dialog/EventsDlg.py:72 -#: lib/osci/dialog/EventsDlg.py:78 -#: lib/osci/dialog/ResearchDlg.py:128 -#: lib/osci/dialog/ConstructionDlg.py:442 -#: lib/osci/dialog/DiplomacyDlg.py:101 -#: lib/osci/dialog/PlanetsOverviewDlg.py:142 -#: lib/osci/dialog/PlanetsOverviewDlg.py:145 -#: lib/osci/dialog/PlanetsOverviewDlg.py:148 -#: lib/osci/dialog/PlanetsOverviewDlg.py:151 -#: lib/osci/dialog/StarSystemDlg.py:551 +#: lib/osci/messages.py:228 +#, fuzzy, python-format +msgid "\"%s\"" +msgstr "%s" + +#: lib/osci/messages.py:232 +#: lib/osci/res.py:176 +#: lib/osci/sequip.py:120 +msgid "N/A" +msgstr "N/A" + +#: lib/osci/messages.py:234 +#: lib/osci/messages.py:241 msgid "-" msgstr "-" -#: lib/osci/messages.py:232 +#: lib/osci/messages.py:235 #, python-format msgid "Source: %s" msgstr "Zdroj: %s" -#: lib/osci/messages.py:239 +#: lib/osci/messages.py:242 #, python-format msgid "Location: %s" msgstr "Místo: %s" -#: lib/osci/messages.py:240 +#: lib/osci/messages.py:243 #, python-format msgid "Severity: %s" msgstr "Závažnost: %s" -#: lib/osci/messages.py:241 +#: lib/osci/messages.py:244 #, python-format msgid "Time: %s [%s]" msgstr "Čas: %s [%s]" +#: lib/osci/client.py:182 +msgid "Deleting obsolete data..." +msgstr "Mažu zastaralá data..." + +#: lib/osci/client.py:202 +msgid "Downloading player data..." +msgstr "Stahuji data hráče..." + +#: lib/osci/client.py:207 +msgid "Updating scanner..." +msgstr "Aktualizuji skener..." + +#: lib/osci/client.py:213 +msgid "Downloading planets and fleets data..." +msgstr "Nahrávám data o planetách a flotilách..." + +#: lib/osci/client.py:243 +msgid "Downloading messages..." +msgstr "Nahrávám zprávy..." + +#: lib/osci/client.py:247 +msgid "Clearing data on the server..." +msgstr "Mažu data na serveru..." + +#: lib/osci/res.py:55 +msgid "Loading resources" +msgstr "Inicializuji klienta" + +#: lib/osci/res.py:62 +#: lib/osci/res.py:77 +#: lib/osci/res.py:93 +#: lib/osci/res.py:104 +#: lib/osci/res.py:118 +#: lib/osci/res.py:127 +#: lib/osci/res.py:136 +msgid "Loading resources..." +msgstr "Nahrávám..." + +#: lib/osci/res.py:173 +msgid "[Unknown]" +msgstr "[Neznámý]" + #: lib/osci/sequip.py:54 #, python-format msgid "power %+d" @@ -626,3066 +1336,1306 @@ msgid "repair %d" msgstr "Opravuje se %d," -#: lib/osci/client.py:167 -msgid "Deleting obsolete data..." -msgstr "Mažu zastaralá data..." +#: lib/osci/dialog/LoginDlg.py:65 +msgid "Auto-login in progress ..." +msgstr "Probíhá automatické přihlašování ..." -#: lib/osci/client.py:187 -msgid "Downloading player data..." -msgstr "Stahuji data hráče..." +#: lib/osci/dialog/LoginDlg.py:76 +msgid "Login in progress ..." +msgstr "Probíhá přihlášení..." -#: lib/osci/client.py:192 -msgid "Updating scanner..." -msgstr "Aktualizuji skener..." +#: lib/osci/dialog/LoginDlg.py:104 +#, fuzzy, python-format +msgid "Your client version does not match server version %d.%d.%d%s. Do you want to continue?" +msgstr "Váš klient je starší než dostupná nová verze (%d.%d.%d%s) [Revize %d]. Chcete pokračovat?" -#: lib/osci/client.py:198 -msgid "Downloading planets and fleets data..." -msgstr "Nahrávám data o planetách a flotilách..." +#: lib/osci/dialog/LoginDlg.py:110 +msgid "Yes" +msgstr "Ano" -#: lib/osci/client.py:228 -msgid "Downloading messages..." -msgstr "Nahrávám zprávy..." +#: lib/osci/dialog/LoginDlg.py:110 +msgid "No" +msgstr "Ne" -#: lib/osci/client.py:232 -msgid "Clearing data on the server..." -msgstr "Mažu data na serveru..." +#: lib/osci/dialog/LoginDlg.py:122 +msgid "Wrong login and/or password" +msgstr "Chybné jméno a/nebo heslo" -#: lib/osci/main.py:71 -msgid "Server sponsored by:" -msgstr "Server sponzorován" +#: lib/osci/dialog/LoginDlg.py:154 +msgid "Outer Space Login" +msgstr "Přihlášení do hry" -#: lib/osci/main.py:75 -#: lib/osci/main.py:219 -#, python-format -msgid "OSCI %s" -msgstr "OSCI %s" +#: lib/osci/dialog/LoginDlg.py:161 +#: lib/osci/dialog/LoginDlg.py:186 +msgid "Login" +msgstr "Login" -#: lib/osci/main.py:78 -#, python-format -msgid "Pygame %s" -msgstr "Pygame %s" +#: lib/osci/dialog/LoginDlg.py:171 +msgid "Password" +msgstr "Heslo" -#: lib/osci/main.py:81 -#, python-format -msgid "Python %s" -msgstr "Python %s" +#: lib/osci/dialog/LoginDlg.py:181 +msgid "Options" +msgstr "Nastavení" -#: lib/osci/main.py:86 -#, python-format -msgid "Video Driver: %s [%dx%dx%d]" -msgstr "Video ovladač: %s [%dx%dx%d]" +#: lib/osci/dialog/LoginDlg.py:182 +msgid "New account" +msgstr "Nový účet" -#: lib/osci/StarMapWidget.py:105 -msgid "Select object" -msgstr "Vyber objekt" +#: lib/osci/dialog/LoginDlg.py:185 +msgid "Exit" +msgstr "Konec" -#: lib/osci/StarMapWidget.py:270 -#: lib/osci/StarMapWidget.py:1155 +#: lib/osci/dialog/FleetsAnalysisDlg.py:85 #, python-format -msgid "System: %s [ID: %d]" -msgstr "Soustava: %s [ID: %d]" +msgid "Fleets contains design %s" +msgstr "Flotily obsahující loď %s" -#: lib/osci/StarMapWidget.py:271 -#: lib/osci/StarMapWidget.py:299 -#: lib/osci/StarMapWidget.py:395 -#: lib/osci/StarMapWidget.py:501 -#, python-format -msgid "Coordinates: [%.2f, %.2f]" -msgstr "Souřadnice: [%.2f, %.2f]" +#: lib/osci/dialog/FleetsAnalysisDlg.py:111 +msgid "Cannot show location" +msgstr "Místo nelze zobrazit" -#: lib/osci/StarMapWidget.py:272 -#: lib/osci/StarMapWidget.py:350 -#: lib/osci/StarMapWidget.py:393 -#: lib/osci/StarMapWidget.py:500 -#: lib/osci/StarMapWidget.py:522 -#, python-format -msgid "Scan pwr: %d" -msgstr "Síla senzorů: %d" +#: lib/osci/dialog/FleetsAnalysisDlg.py:126 +msgid "Fleets analysis" +msgstr "Analýza flotil" -#: lib/osci/StarMapWidget.py:273 -#, python-format -msgid "Star Class: %s" -msgstr "Třída hvězdy : %s" +#: lib/osci/dialog/FleetsAnalysisDlg.py:135 +msgid "Ship designs" +msgstr "Návrhy lodí" -#: lib/osci/StarMapWidget.py:274 -#, python-format -msgid "Star Type: %s" -msgstr "Typ hvězdy: %s" +#: lib/osci/dialog/FleetsAnalysisDlg.py:139 +msgid "Design name" +msgstr "Jméno lodi" -#: lib/osci/StarMapWidget.py:276 -#, python-format -msgid "Refuel: %d %%/turn [%d %% max]" -msgstr "Tankování: %d %%/tah [%d %% max]" +#: lib/osci/dialog/FleetsAnalysisDlg.py:140 +msgid "# fleets" +msgstr "č. flotily" -#: lib/osci/StarMapWidget.py:278 -#, python-format -msgid "Repair ratio: %d %%/turn" -msgstr "Rychlost oprav: %d %%/tah" +#: lib/osci/dialog/FleetsAnalysisDlg.py:148 +msgid "Fleet name" +msgstr "Jméno flotily" -#: lib/osci/StarMapWidget.py:280 -#, python-format -msgid "Upgrade points: %d/turn" -msgstr "Modernizační body: %d/tah" +#: lib/osci/dialog/FleetsAnalysisDlg.py:149 +msgid "Ships" +msgstr "Lodě" -#: lib/osci/StarMapWidget.py:282 -#, python-format -msgid "Fleet speed: +%d %%" -msgstr "Rychlost flotily: +%d %%" +#: lib/osci/dialog/FleetsAnalysisDlg.py:150 +msgid "Fleet size" +msgstr "Velikost flotily" -#: lib/osci/StarMapWidget.py:284 -#: lib/osci/StarMapWidget.py:311 -#, python-format -msgid "Pirate get fame chance: %d %%" -msgstr "Šance piráta získat slávu: %d %%" +#: lib/osci/dialog/FleetsAnalysisDlg.py:156 +msgid "Close" +msgstr "Zavřít" -#: lib/osci/StarMapWidget.py:298 -#: lib/osci/StarMapWidget.py:1158 -#, python-format -msgid "Worm hole: %s [ID: %d]" -msgstr "Červí díra: %s [ID: %d]" +#: lib/osci/dialog/UpdateDlg.py:48 +msgid "Client is up-to-date" +msgstr "" -#: lib/osci/StarMapWidget.py:304 -#, python-format -msgid "Destination: %s [ID: %d]" -msgstr "Cíl: %s [ID: %d]" +#: lib/osci/dialog/UpdateDlg.py:59 +msgid "Updating client..." +msgstr "Aktualizuji klienta..." -#: lib/osci/StarMapWidget.py:305 -#, python-format -msgid "Dest. Coords: [%.2f, %.2f]" -msgstr "Souř. cíle: [%.2f, %.2f]" +#: lib/osci/dialog/UpdateDlg.py:87 +msgid "Error: URL does not point to a file." +msgstr "" -#: lib/osci/StarMapWidget.py:308 -msgid "Destination: ? [ID: ?]" -msgstr "Cíl: ? [ID: ?]" +#: lib/osci/dialog/UpdateDlg.py:106 +msgid "Cannot finish download: %(s)" +msgstr "" -#: lib/osci/StarMapWidget.py:309 -msgid "Dest. Coords: [?, ?]" -msgstr "Cíl. souřadnice: [?, ?]" - -#: lib/osci/StarMapWidget.py:349 -#: lib/osci/StarMapWidget.py:1161 +#: lib/osci/dialog/UpdateDlg.py:118 #, python-format -msgid "Planet: %s [ID: %d]" -msgstr "Planeta: %s [ID: %d]" +msgid "Cannot run %s." +msgstr "" -#: lib/osci/StarMapWidget.py:351 -#: lib/osci/StarMapWidget.py:394 -#, python-format -msgid "Scanner pwr: %d" -msgstr "Síla skeneru: %d" +#: lib/osci/dialog/UpdateDlg.py:124 +#: lib/osci/dialog/ChangeQtyDlg.py:88 +msgid "OK" +msgstr "OK" -#: lib/osci/StarMapWidget.py:353 -#, python-format -msgid "Type: %s" -msgstr "Typ: %s" +#: lib/osci/dialog/UpdateDlg.py:141 +msgid "Update skipped." +msgstr "" -#: lib/osci/StarMapWidget.py:354 -#, python-format -msgid "Environment: %d" -msgstr "Životní prostř.: %d" +#: lib/osci/dialog/UpdateDlg.py:161 +msgid "Server does not support update feature yet. Check for updates manually, please." +msgstr "" -#: lib/osci/StarMapWidget.py:355 +#: lib/osci/dialog/UpdateDlg.py:179 #, python-format -msgid "Minerals: %d" -msgstr "Minerály: %d" +msgid "Server requires client version %s. It is recommended to update your client." +msgstr "" -#: lib/osci/StarMapWidget.py:356 -#, python-format -msgid "Energy: %d" -msgstr "Energie: %d" +#: lib/osci/dialog/UpdateDlg.py:183 +msgid "Do you want to display download page?" +msgstr "" -#: lib/osci/StarMapWidget.py:357 -#, python-format -msgid "Slots: %d" -msgstr "slotů: %d" +#: lib/osci/dialog/UpdateDlg.py:187 +msgid "Do you want to download and install new version?" +msgstr "" -#: lib/osci/StarMapWidget.py:359 -#, python-format -msgid "Strat. resource: %s" -msgstr "Strategický zdroj: %s" +#: lib/osci/dialog/UpdateDlg.py:191 +msgid "Unsupported update type." +msgstr "" -#: lib/osci/StarMapWidget.py:362 -#: lib/osci/StarMapWidget.py:401 -#: lib/osci/StarMapWidget.py:510 -#, python-format -msgid "Owner: %s [ID: %s]" -msgstr "Vlastník: %s [ID: %s]" +#: lib/osci/dialog/UpdateDlg.py:199 +msgid "Outer Space Update Available" +msgstr "" -#: lib/osci/StarMapWidget.py:392 -#: lib/osci/StarMapWidget.py:1164 -#, python-format -msgid "Fleet: %s [ID: %d]" -msgstr "Flotila: %s [ID: %d]" +#: lib/osci/dialog/ConfirmDlg.py:64 +msgid "Question" +msgstr "Otázka" -#: lib/osci/StarMapWidget.py:396 -#: lib/osci/StarMapWidget.py:502 -#, python-format -msgid "Signature: %d" -msgstr "Signatura: %d" +#: lib/osci/dialog/NewAccountDlg.py:35 +msgid "No free starting position" +msgstr "Není žádná volná počáteční pozice" -#: lib/osci/StarMapWidget.py:398 -#: lib/osci/StarMapWidget.py:507 -#, python-format -msgid "ETA: %s" -msgstr "ETA: %s" +#: lib/osci/dialog/NewAccountDlg.py:50 +msgid "We are sorry, but there are no starting positions available at this moment. Please, try again later." +msgstr "Litujeme, ale v této chvíli nejsou k dispozici žádné startovní posice. Zkuste později, prosím." -#: lib/osci/StarMapWidget.py:408 -#, python-format -msgid "Tanks: %d / %d [%d %%]" -msgstr "Nádrže: %d / %d [%d %%]" +#: lib/osci/dialog/NewAccountDlg.py:51 +#: lib/osci/dialog/MessagesDlg.py:466 +msgid "Refresh" +msgstr "Obnovit" -#: lib/osci/StarMapWidget.py:409 -#, python-format -msgid "Support (fuel): %d/turn" -msgstr "Podpora (palivo): %d/tah" +#: lib/osci/dialog/NewAccountDlg.py:58 +msgid "Independent player" +msgstr "Nezávislý hráč" -#: lib/osci/StarMapWidget.py:410 -#, python-format -msgid "Support (const. pts): %d/turn" -msgstr "Podpora (konst. body): %d/tah" +#: lib/osci/dialog/NewAccountDlg.py:60 +msgid "Rebel faction" +msgstr "Vzbouřenecká frakce" -#: lib/osci/StarMapWidget.py:412 -#, python-format -msgid "Military power: %d" -msgstr "Vojenská síla: %d" +#: lib/osci/dialog/NewAccountDlg.py:62 +msgid "Pirate faction [VIP password needed]" +msgstr "Pirát [vyžaduje VIP heslo]" -#: lib/osci/StarMapWidget.py:419 -#, python-format -msgid "Operational time: %s" -msgstr "Provozní čas: %s" +#: lib/osci/dialog/NewAccountDlg.py:64 +msgid "Unknown. You cannot use this." +msgstr "Neznámé. Tohle nemůžeš použít." -#: lib/osci/StarMapWidget.py:424 -#, python-format -msgid "Target: %s" -msgstr "Cíl: %s" +#: lib/osci/dialog/NewAccountDlg.py:71 +msgid "Select position." +msgstr "Vyberte pozici." -#: lib/osci/StarMapWidget.py:427 -#: lib/osci/StarMapWidget.py:447 -msgid "Ships:" -msgstr "Lodě:" +#: lib/osci/dialog/NewAccountDlg.py:75 +msgid "Executing CREATE NEW PLAYER command..." +msgstr "Vykonávám příkaz VYTVOŘ NOVÉHO HRÁČE..." -#: lib/osci/StarMapWidget.py:440 -#, python-format -msgid " %d x %s [%d, %d, %d, %d, %d]" -msgstr " %d x %s [%d, %d, %d, %d, %d]" - -#: lib/osci/StarMapWidget.py:450 -msgid "military" -msgstr "vojenská" - -#: lib/osci/StarMapWidget.py:452 -msgid "civilian" -msgstr "civilní" - -#: lib/osci/StarMapWidget.py:453 -#, python-format -msgid " %d x %s [%s %s ship]" -msgstr " %d x %s [%s %s loď]" - -#: lib/osci/StarMapWidget.py:465 -#, python-format -msgid "Command: %s %s" -msgstr "Příkaz: %s %s" - -#: lib/osci/StarMapWidget.py:499 -#: lib/osci/StarMapWidget.py:1167 -#, python-format -msgid "Asteroid: %s [ID: %d]" -msgstr "Asteroid: %s [ID: %d]" - -#: lib/osci/StarMapWidget.py:503 -#, python-format -msgid "Diameter: %d" -msgstr "Průměr: %d" - -#: lib/osci/StarMapWidget.py:504 -#, python-format -msgid "HP: %d" -msgstr "HP: %d" - -#: lib/osci/StarMapWidget.py:505 -#, python-format -msgid "Speed: %.2f" -msgstr "Rychlost: %.2f" - -#: lib/osci/StarMapWidget.py:520 -#: lib/osci/StarMapWidget.py:1169 -#, python-format -msgid "Unknown object [ID: %d]" -msgstr "Neznámý objekt [ID: %d]" - -#: lib/osci/StarMapWidget.py:1003 -msgid "Overlay Mode: " -msgstr "Překrytí mapy: " - -#: lib/osci/StarMapWidget.py:1005 -msgid "Normal" -msgstr "Normální" - -#: lib/osci/StarMapWidget.py:1007 -msgid "Diplomatic" -msgstr "Diplomacie" - -#: lib/osci/StarMapWidget.py:1009 -#: lib/osci/dialog/MapOverlayDlg.py:125 -#: lib/osci/dialog/StarSystemDlg.py:1231 -msgid "Environment" -msgstr "Prostředí" - -#: lib/osci/StarMapWidget.py:1011 -#: lib/osci/dialog/MapOverlayDlg.py:137 -msgid "Pirate Fame" -msgstr "Pověst pirátů" - -#: lib/osci/StarMapWidget.py:1013 -#: lib/osci/dialog/MapOverlayDlg.py:127 -msgid "Minerals" -msgstr "Minerály" - -#: lib/osci/StarMapWidget.py:1015 -#: lib/osci/dialog/MapOverlayDlg.py:129 -#: lib/osci/dialog/TechInfoDlg.py:155 -msgid "Slots" -msgstr "Sloty" - -#: lib/osci/StarMapWidget.py:1017 -#: lib/osci/dialog/MapOverlayDlg.py:131 -msgid "Fleet Acceleration" -msgstr "Zrychlení flotily" - -#: lib/osci/StarMapWidget.py:1019 -msgid "Refuel and Repair" -msgstr "Tankování a opravy" - -#: lib/osci/StarMapWidget.py:1021 -#: lib/osci/dialog/MapOverlayDlg.py:135 -#: lib/osci/dialog/NewTaskDlg.py:405 -#: lib/osci/dialog/StructTaskDlg.py:312 -#: lib/osci/dialog/StarSystemDlg.py:1300 -msgid "Morale" -msgstr "Morálka" - -#: lib/osci/StarMapWidget.py:1176 -#, python-format -msgid "Buoy on system: %s [ID: %d]" -msgstr "Bójka na soustavě: %s [ID: %d]" - -#: lib/osci/StarMapWidget.py:1179 -#, python-format -msgid "Buoy on worm hole: %s [ID: %d]" -msgstr "Bójka na červí díře: %s [ID: %d]" - -#: lib/osci/StarMapWidget.py:1181 -#, python-format -msgid "Buoy on unknown object [ID: %d]" -msgstr "Bójka na neznámém objektu [ID: %d]" - -#: lib/osci/gdata.py:36 -msgid "Asteroid" -msgstr "Asteroid" - -#: lib/osci/gdata.py:37 -msgid "Gas Giant" -msgstr "Plynný obr" - -#: lib/osci/gdata.py:38 -msgid "Rock" -msgstr "Skalnatá" - -#: lib/osci/gdata.py:39 -msgid "Cold" -msgstr "Ledová" - -#: lib/osci/gdata.py:40 -msgid "Desert" -msgstr "Pouštní" - -#: lib/osci/gdata.py:41 -msgid "Hostile" -msgstr "Nepříznivá" - -#: lib/osci/gdata.py:42 -msgid "Marginal" -msgstr "Neúrodná" - -#: lib/osci/gdata.py:43 -msgid "Terrestrial" -msgstr "Pozemská" - -#: lib/osci/gdata.py:44 -msgid "Gaia" -msgstr "Gaia" - -#: lib/osci/gdata.py:45 -#: lib/osci/dialog/TechInfoDlg.py:70 -#: lib/osci/dialog/TechInfoDlg.py:79 -msgid "Unknown" -msgstr "Neznámý" - -#: lib/osci/gdata.py:49 -msgid "Super giant" -msgstr "Veleobr" - -#: lib/osci/gdata.py:50 -msgid "Giant" -msgstr "Obr" - -#: lib/osci/gdata.py:51 -msgid "Main sequence" -msgstr "Hlavní sekvence" - -#: lib/osci/gdata.py:52 -msgid "Dwarf" -msgstr "Trpaslík" - -#: lib/osci/gdata.py:53 -msgid "Black hole" -msgstr "Černá díra" - -#: lib/osci/gdata.py:54 -msgid "Neutron star" -msgstr "Neutronová hvězda" - -#: lib/osci/gdata.py:55 -msgid "Worm hole" -msgstr "Červí díra" - -#: lib/osci/gdata.py:59 -#: lib/osci/dialog/TechInfoDlg.py:28 -msgid "small" -msgstr "malá" - -#: lib/osci/gdata.py:60 -#: lib/osci/dialog/TechInfoDlg.py:28 -msgid "medium" -msgstr "střední" - -#: lib/osci/gdata.py:61 -#: lib/osci/dialog/TechInfoDlg.py:28 -msgid "large" -msgstr "velká" - -#: lib/osci/gdata.py:62 -#: lib/osci/dialog/TechInfoDlg.py:28 -msgid "planet" -msgstr "planeta" - -#: lib/osci/gdata.py:66 -#: lib/osci/gdata.py:78 -#: lib/osci/dialog/ConstructionDlg.py:210 -#: lib/osci/dialog/DiplomacyDlg.py:116 -#: lib/osci/dialog/StarSystemDlg.py:720 -#: lib/osci/dialog/StarSystemDlg.py:734 -msgid "None" -msgstr "Žádný" - -#: lib/osci/gdata.py:67 -msgid "Move to" -msgstr "Přesun" - -#: lib/osci/gdata.py:68 -msgid "Declare War at" -msgstr "Vyhlaš válku" - -#: lib/osci/gdata.py:69 -msgid "Deploy Ship" -msgstr "Rozlož loď" - -#: lib/osci/gdata.py:70 -msgid "Redirect to" -msgstr "Přesměrovat do" - -#: lib/osci/gdata.py:71 -#: lib/osci/dialog/FleetCommandDlg.py:292 -msgid "Refuel at" -msgstr "Natankuj na" - -#: lib/osci/gdata.py:72 -msgid "Repeat from" -msgstr "Opakovat od" - -#: lib/osci/gdata.py:73 -#: lib/osci/dialog/FleetCommandDlg.py:296 -msgid "Wait" -msgstr "Čekat" - -#: lib/osci/gdata.py:74 -msgid "Enter Wormhole at" -msgstr "Vstup do červí díry v" - -#: lib/osci/gdata.py:79 -msgid "Uranium" -msgstr "Uran" - -#: lib/osci/gdata.py:80 -msgid "Titanium" -msgstr "Titan" - -#: lib/osci/gdata.py:81 -msgid "Chromium" -msgstr "Chrom" - -#: lib/osci/gdata.py:82 -msgid "Silicium" -msgstr "Silicium" - -#: lib/osci/gdata.py:83 -msgid "Carboneum" -msgstr "Carboneum" - -#: lib/osci/gdata.py:84 -msgid "Antimatter" -msgstr "Antihmota" - -#: lib/osci/gdata.py:85 -msgid "Plutonium" -msgstr "Plutonium" - -#: lib/osci/gdata.py:86 -msgid "Wolframium" -msgstr "Wolframium" - -#: lib/osci/gdata.py:87 -msgid "Mutagen" -msgstr "Mutagen" - -#: lib/osci/gdata.py:88 -msgid "Unnilseptium" -msgstr "Unnilseptium" - -#: lib/osci/gdata.py:91 -#: lib/osci/dialog/FleetsOverviewDlg.py:250 -msgid "Enemy" -msgstr "Nepřítel" - -#: lib/osci/gdata.py:91 -#: lib/osci/dialog/FleetsOverviewDlg.py:252 -msgid "Unfriendly" -msgstr "Nepřátelský" - -#: lib/osci/gdata.py:91 -#: lib/osci/gdata.py:92 -#: lib/osci/dialog/FleetsOverviewDlg.py:254 -msgid "Neutral" -msgstr "Neutrální" - -#: lib/osci/gdata.py:92 -#: lib/osci/dialog/FleetsOverviewDlg.py:256 -msgid "Friendly" -msgstr "Přítel" - -#: lib/osci/gdata.py:92 -#: lib/osci/dialog/FleetsOverviewDlg.py:258 -msgid "Allied" -msgstr "Spojenec" - -#: lib/osci/gdata.py:95 -msgid "Passage for civilian ships" -msgstr "Přelet pro civilní lodě" - -#: lib/osci/gdata.py:96 -msgid "Passage for military ships" -msgstr "Přelet pro válečné lodě" - -#: lib/osci/gdata.py:97 -msgid "Permission to tank ships" -msgstr "Povolení doplňovat palivo pro lodě" - -#: lib/osci/gdata.py:98 -msgid "Limited trade agreement" -msgstr "Omezený obchodní pakt" - -#: lib/osci/gdata.py:99 -msgid "Unlimited trade agreement" -msgstr "Neomezený obchodní pakt" - -#: lib/osci/gdata.py:100 -msgid "Scanner map exchange" -msgstr "Výměna hvězdných map ze skeneru" - -#: lib/osci/gdata.py:101 -msgid "Research information exchange" -msgstr "Výměna informací z výzkumu" - -#: lib/osci/gdata.py:102 -msgid "Research cooperation" -msgstr "Spolupráce při výzkumu" - -#: lib/osci/gdata.py:116 -#: lib/osci/gdata.py:158 -msgid "Disabled" -msgstr "Vypnuto" - -#: lib/osci/gdata.py:116 -msgid "Enabled" -msgstr "Zapnuto" - -#: lib/osci/gdata.py:116 -msgid "Active" -msgstr "Aktivní" - -#: lib/osci/gdata.py:119 -msgid "Mailbox" -msgstr "Schránka" - -#: lib/osci/gdata.py:120 -msgid "Sent" -msgstr "Odesláno" - -#: lib/osci/gdata.py:121 -#: lib/osci/dialog/EventsDlg.py:170 -msgid "Events" -msgstr "Události" - -#: lib/osci/gdata.py:122 -msgid "News" -msgstr "Novinky" - -#: lib/osci/gdata.py:123 -msgid "QA channel" -msgstr "Otázky/Odpovědi" - -#: lib/osci/gdata.py:124 -msgid "Issues" -msgstr "Chyby" - -#: lib/osci/gdata.py:125 -msgid "Suggestions" -msgstr "Návrhy" - -#: lib/osci/gdata.py:126 -#: lib/osci/gdata.py:127 -msgid "Public channel" -msgstr "Veřejný kanál" - -#: lib/osci/gdata.py:128 -msgid "News channel" -msgstr "Novinky" - -#: lib/osci/gdata.py:133 -#: lib/osci/gdata.py:134 -#: lib/osci/gdata.py:135 -msgid "MORALE IS TERRIBLE" -msgstr "MORÁLKA JE HROZNÁ" - -#: lib/osci/gdata.py:136 -msgid "MORALE IS BAD" -msgstr "MORÁLKA JE ŠPATNÁ" - -#: lib/osci/gdata.py:137 -msgid "MORALE IS VERY LOW" -msgstr "MORÁLKA JE VELMI NÍZKÁ" - -#: lib/osci/gdata.py:138 -msgid "MORALE IS LOW" -msgstr "MORÁLKA JE NÍZKÁ" - -#: lib/osci/gdata.py:139 -msgid "MORALE IS BELOW AVERAGE" -msgstr "MORÁLKA JE PODPRŮMĚRNÁ" - -#: lib/osci/gdata.py:140 -#: lib/osci/dialog/MessagesDlg.py:227 -#: lib/osci/dialog/MessagesDlg.py:236 -#: lib/osci/dialog/MessagesDlg.py:384 -#: lib/osci/dialog/ConstructionDlg.py:302 -#: lib/osci/dialog/ConstructionDlg.py:309 -#: lib/osci/dialog/FleetSpecsDlg.py:188 -#: lib/osci/dialog/FleetSpecsDlg.py:195 -#: lib/osci/dialog/FleetSpecsDlg.py:202 -#: lib/osci/dialog/FleetSpecsDlg.py:212 -#: lib/osci/dialog/FleetSpecsDlg.py:215 -#: lib/osci/dialog/FleetSpecsDlg.py:218 -#: lib/osci/dialog/FleetSpecsDlg.py:221 -#: lib/osci/dialog/FleetSpecsDlg.py:225 -#: lib/osci/dialog/DiplomacyDlg.py:241 -msgid " " -msgstr " " - -#: lib/osci/gdata.py:141 -msgid "MORALE IS HIGH" -msgstr "MORÁLKA JE VYSOKÁ" - -#: lib/osci/gdata.py:142 -msgid "MORALE IS SUPERB" -msgstr "MORÁLKA JE VÝBORNÁ" - -#: lib/osci/gdata.py:154 -#: lib/osci/dialog/ProblemsDlg.py:449 -msgid "Critical" -msgstr "Kritická" - -#: lib/osci/gdata.py:155 -#: lib/osci/dialog/ProblemsDlg.py:451 -msgid "Major" -msgstr "Velká" - -#: lib/osci/gdata.py:156 -#: lib/osci/dialog/ProblemsDlg.py:453 -msgid "Minor" -msgstr "Malá" - -#: lib/osci/gdata.py:157 -#: lib/osci/dialog/NewTaskDlg.py:383 -#: lib/osci/dialog/ResearchDlg.py:328 -#: lib/osci/dialog/ResearchDlg.py:339 -#: lib/osci/dialog/ResearchDlg.py:365 -#: lib/osci/dialog/FleetDlg.py:365 -#: lib/osci/dialog/ProblemsDlg.py:455 -#: lib/osci/dialog/StarSystemDlg.py:1379 -#: lib/osci/dialog/StarSystemDlg.py:1450 -msgid "Info" -msgstr "Informace" - -#: lib/osci/dialog/MapOverlayDlg.py:48 -#: lib/osci/dialog/PlanetsAnalysisDlg.py:44 -#: lib/osci/dialog/NewTaskDlg.py:68 -#: lib/osci/dialog/EventsDlg.py:43 -#: lib/osci/dialog/EmpireOverviewDlg.py:50 -#: lib/osci/dialog/TechInfoDlg.py:195 -#: lib/osci/dialog/ConstrUpgradeDlg.py:47 -#: lib/osci/dialog/SystemOverviewDlg.py:48 -#: lib/osci/dialog/FleetSplitDlg.py:198 -#: lib/osci/dialog/ChangeQtyDlg.py:40 -#: lib/osci/dialog/FleetMassRedirectionDlg.py:52 -#: lib/osci/dialog/RenameSysDlg.py:43 -#: lib/osci/dialog/ResearchDlg.py:48 -#: lib/osci/dialog/MessagesDlg.py:53 -#: lib/osci/dialog/FleetDlg.py:59 -#: lib/osci/dialog/ConstructionDlg.py:53 -#: lib/osci/dialog/ConstructionDlg.py:156 -#: lib/osci/dialog/FleetCommandDlg.py:62 -#: lib/osci/dialog/BuoyDlg.py:44 -#: lib/osci/dialog/ExceptionDlg.py:57 -#: lib/osci/dialog/MinefieldDlg.py:58 -#: lib/osci/dialog/ProblemsDlg.py:44 -#: lib/osci/dialog/FleetSpecsDlg.py:85 -#: lib/osci/dialog/ShowBuoyDlg.py:58 -#: lib/osci/dialog/GalaxyRestartDlg.py:46 -#: lib/osci/dialog/StructTaskDlg.py:62 -#: lib/osci/dialog/OptionsDlg.py:57 -#: lib/osci/dialog/ConstrSelTechDlg.py:72 -#: lib/osci/dialog/DiplomacyDlg.py:52 -#: lib/osci/dialog/MainGameDlg.py:325 -#: lib/osci/dialog/NewMessageDlg.py:64 -#: lib/osci/dialog/FleetRedirectionDlg.py:52 -#: lib/osci/dialog/RenameFleetDlg.py:59 -#: lib/osci/dialog/FleetsOverviewDlg.py:46 -#: lib/osci/dialog/ColorDefinitionDlg.py:61 -#: lib/osci/dialog/FleetsAnalysisDlg.py:45 -#: lib/osci/dialog/SearchDlg.py:54 -#: lib/osci/dialog/PlanetsOverviewDlg.py:47 -#: lib/osci/dialog/StarSystemDlg.py:108 -msgid "Ready." -msgstr "Připraven." - -#: lib/osci/dialog/MapOverlayDlg.py:115 -msgid "Set Map Overlay:" -msgstr "Typ zobrazované mapy:" - -#: lib/osci/dialog/MapOverlayDlg.py:121 -msgid "Standard" -msgstr "Standardní" - -#: lib/osci/dialog/MapOverlayDlg.py:123 -#: lib/osci/dialog/DiplomacyDlg.py:358 -#: lib/osci/dialog/MainGameDlg.py:309 -msgid "Diplomacy" -msgstr "Diplomacie" - -#: lib/osci/dialog/MapOverlayDlg.py:133 -msgid "Refuel and Upgrade" -msgstr "Tankování a upgrade" - -#: lib/osci/dialog/MapOverlayDlg.py:141 -#: lib/osci/dialog/PlanetsAnalysisDlg.py:152 -#: lib/osci/dialog/EventsDlg.py:190 -#: lib/osci/dialog/EmpireOverviewDlg.py:274 -#: lib/osci/dialog/TechInfoDlg.py:404 -#: lib/osci/dialog/SystemOverviewDlg.py:240 -#: lib/osci/dialog/ResearchDlg.py:314 -#: lib/osci/dialog/MessagesDlg.py:408 -#: lib/osci/dialog/FleetDlg.py:338 -#: lib/osci/dialog/ConstructionDlg.py:491 -#: lib/osci/dialog/MinefieldDlg.py:129 -#: lib/osci/dialog/ProblemsDlg.py:459 -#: lib/osci/dialog/FleetSpecsDlg.py:272 -#: lib/osci/dialog/DiplomacyDlg.py:419 -#: lib/osci/dialog/FleetsOverviewDlg.py:263 -#: lib/osci/dialog/FleetsAnalysisDlg.py:156 -#: lib/osci/dialog/_Template.py:73 -#: lib/osci/dialog/PlanetsOverviewDlg.py:277 -#: lib/osci/dialog/StarSystemDlg.py:1177 -msgid "Close" -msgstr "Zavřít" - -#: lib/osci/dialog/PlanetsAnalysisDlg.py:88 -#, python-format -msgid "Planets with structure %s" -msgstr "Planety s budovou %s" - -#: lib/osci/dialog/PlanetsAnalysisDlg.py:108 -#: lib/osci/dialog/EventsDlg.py:146 -#: lib/osci/dialog/EventsDlg.py:158 -#: lib/osci/dialog/SystemOverviewDlg.py:181 -#: lib/osci/dialog/SystemOverviewDlg.py:191 -#: lib/osci/dialog/MessagesDlg.py:341 -#: lib/osci/dialog/MessagesDlg.py:356 -#: lib/osci/dialog/FleetsOverviewDlg.py:201 -#: lib/osci/dialog/FleetsOverviewDlg.py:212 -#: lib/osci/dialog/FleetsAnalysisDlg.py:111 -#: lib/osci/dialog/PlanetsOverviewDlg.py:217 -#: lib/osci/dialog/PlanetsOverviewDlg.py:228 -msgid "Cannot show location" -msgstr "Místo nelze zobrazit" - -#: lib/osci/dialog/PlanetsAnalysisDlg.py:123 -msgid "Planets analysis" -msgstr "Analýza planet" - -#: lib/osci/dialog/PlanetsAnalysisDlg.py:132 -#: lib/osci/dialog/EmpireOverviewDlg.py:121 -#: lib/osci/dialog/DiplomacyDlg.py:372 -#: lib/osci/dialog/StarSystemDlg.py:1215 -msgid "Structures" -msgstr "Budovy" - -#: lib/osci/dialog/PlanetsAnalysisDlg.py:136 -msgid "Structure name" -msgstr "Název budovy" - -#: lib/osci/dialog/PlanetsAnalysisDlg.py:137 -msgid "Total #" -msgstr "Celkem #" - -#: lib/osci/dialog/PlanetsAnalysisDlg.py:145 -msgid "Planet name" -msgstr "Jméno planety" - -#: lib/osci/dialog/PlanetsAnalysisDlg.py:146 -msgid "# of structs" -msgstr "# budov" - -#: lib/osci/dialog/NewTaskDlg.py:205 -#: lib/osci/dialog/PlanetsOverviewDlg.py:96 -#: lib/osci/dialog/StarSystemDlg.py:541 -msgid "[Nobody]" -msgstr "[Nikdo]" - -#: lib/osci/dialog/NewTaskDlg.py:235 -msgid "Free slot" -msgstr "Volný slot" - -#: lib/osci/dialog/NewTaskDlg.py:275 -#: lib/osci/dialog/StructTaskDlg.py:207 -msgid "Select technology to construct." -msgstr "Vyberte technologii, kterou chcete postavit." - -#: lib/osci/dialog/NewTaskDlg.py:278 -msgid "Select planet to construct on." -msgstr "Vyberte planetu, na kterou se má stavět." - -#: lib/osci/dialog/NewTaskDlg.py:283 -#: lib/osci/dialog/ChangeQtyDlg.py:53 -#: lib/osci/dialog/StructTaskDlg.py:216 -msgid "Specify quantity (1, 2, 3, ...)." -msgstr "Zadejte množství (1, 2, 3, ...)" - -#: lib/osci/dialog/NewTaskDlg.py:286 -#: lib/osci/dialog/StructTaskDlg.py:220 -msgid "Executing START CONSTRUCTION command..." -msgstr "Vykonávám příkaz NOVÝ KONSTRUKČNÍ ÚKOL..." - -#: lib/osci/dialog/NewTaskDlg.py:292 -#: lib/osci/dialog/EventsDlg.py:116 -#: lib/osci/dialog/EventsDlg.py:126 -#: lib/osci/dialog/ConstrUpgradeDlg.py:107 -#: lib/osci/dialog/FleetSplitDlg.py:344 -#: lib/osci/dialog/FleetMassRedirectionDlg.py:82 -#: lib/osci/dialog/RenameSysDlg.py:82 -#: lib/osci/dialog/ResearchDlg.py:235 -#: lib/osci/dialog/ResearchDlg.py:251 -#: lib/osci/dialog/ResearchDlg.py:269 -#: lib/osci/dialog/ResearchDlg.py:281 -#: lib/osci/dialog/ResearchDlg.py:298 -#: lib/osci/dialog/FleetDlg.py:225 -#: lib/osci/dialog/FleetDlg.py:240 -#: lib/osci/dialog/FleetDlg.py:256 -#: lib/osci/dialog/FleetDlg.py:275 -#: lib/osci/dialog/FleetDlg.py:286 -#: lib/osci/dialog/FleetDlg.py:308 -#: lib/osci/dialog/ConstructionDlg.py:256 -#: lib/osci/dialog/ConstructionDlg.py:358 -#: lib/osci/dialog/ConstructionDlg.py:380 -#: lib/osci/dialog/FleetCommandDlg.py:265 -#: lib/osci/dialog/StructTaskDlg.py:236 -#: lib/osci/dialog/DiplomacyDlg.py:279 -#: lib/osci/dialog/DiplomacyDlg.py:292 -#: lib/osci/dialog/DiplomacyDlg.py:303 -#: lib/osci/dialog/NewMessageDlg.py:162 -#: lib/osci/dialog/FleetRedirectionDlg.py:88 -#: lib/osci/dialog/FleetRedirectionDlg.py:101 #: lib/osci/dialog/NewAccountDlg.py:77 #: lib/osci/dialog/NewAccountDlg.py:86 #: lib/osci/dialog/NewAccountDlg.py:103 +#: lib/osci/dialog/ResearchDlg.py:242 +#: lib/osci/dialog/ResearchDlg.py:258 +#: lib/osci/dialog/ResearchDlg.py:276 +#: lib/osci/dialog/ResearchDlg.py:288 +#: lib/osci/dialog/ResearchDlg.py:305 +#: lib/osci/dialog/FleetSplitDlg.py:357 +#: lib/osci/dialog/StructTaskDlg.py:246 +#: lib/osci/dialog/NewTaskDlg.py:294 #: lib/osci/dialog/RenameFleetDlg.py:77 #: lib/osci/dialog/RenameFleetDlg.py:92 -#: lib/osci/dialog/StarSystemDlg.py:917 -#: lib/osci/dialog/StarSystemDlg.py:937 -#: lib/osci/dialog/StarSystemDlg.py:951 -#: lib/osci/dialog/StarSystemDlg.py:967 -#: lib/osci/dialog/StarSystemDlg.py:993 -#: lib/osci/dialog/StarSystemDlg.py:1006 -#: lib/osci/dialog/StarSystemDlg.py:1030 -#: lib/osci/dialog/StarSystemDlg.py:1044 -#: lib/osci/dialog/StarSystemDlg.py:1100 -#: lib/osci/dialog/StarSystemDlg.py:1112 -#: lib/osci/dialog/StarSystemDlg.py:1139 -#: lib/osci/dialog/StarSystemDlg.py:1150 +#: lib/osci/dialog/FleetRedirectionDlg.py:88 +#: lib/osci/dialog/FleetRedirectionDlg.py:101 msgid "Command has been executed." msgstr "Příkaz byl úspěšně vykonán." -#: lib/osci/dialog/NewTaskDlg.py:346 -msgid "Select new task" -msgstr "Vyberte nový úkol" +#: lib/osci/dialog/NewAccountDlg.py:84 +msgid "Executing TAKE OVER REBEL FACTION command..." +msgstr "Vykonávám příkaz OBSAĎ VZBOUŘENECKOU FRAKCI..." -#: lib/osci/dialog/NewTaskDlg.py:352 -msgid "Technology" -msgstr "Technologie" +#: lib/osci/dialog/NewAccountDlg.py:95 +msgid "Supply VIP password, please." +msgstr "Zadejte VIP heslo, prosím." -#: lib/osci/dialog/NewTaskDlg.py:355 -#: lib/osci/dialog/ConstrUpgradeDlg.py:131 -#: lib/osci/dialog/FleetSplitDlg.py:504 -#: lib/osci/dialog/FleetSplitDlg.py:542 -#: lib/osci/dialog/RenameSysDlg.py:106 -#: lib/osci/dialog/ResearchDlg.py:321 -#: lib/osci/dialog/ResearchDlg.py:334 -#: lib/osci/dialog/ResearchDlg.py:347 -#: lib/osci/dialog/FleetDlg.py:343 -#: lib/osci/dialog/FleetDlg.py:394 -#: lib/osci/dialog/FleetDlg.py:417 -#: lib/osci/dialog/ConstructionDlg.py:405 -#: lib/osci/dialog/ConstructionDlg.py:418 -#: lib/osci/dialog/ConstructionDlg.py:435 -#: lib/osci/dialog/ConstrSelTechDlg.py:157 -#: lib/osci/dialog/DiplomacyDlg.py:368 -#: lib/osci/dialog/RenameFleetDlg.py:128 -msgid "Name" -msgstr "Jméno" +#: lib/osci/dialog/NewAccountDlg.py:97 +msgid "Executing TAKE OVER PIRATE FACTION command..." +msgstr "Vykonávám příkaz OBSAĎ PIRÁTSKOU FRAKCI..." -#: lib/osci/dialog/NewTaskDlg.py:355 -#: lib/osci/dialog/FleetSplitDlg.py:505 -#: lib/osci/dialog/FleetSplitDlg.py:543 -#: lib/osci/dialog/ResearchDlg.py:321 -#: lib/osci/dialog/ResearchDlg.py:334 -#: lib/osci/dialog/ResearchDlg.py:348 -#: lib/osci/dialog/FleetDlg.py:344 -msgid "Lvl" -msgstr "Úrvň" +#: lib/osci/dialog/NewAccountDlg.py:101 +msgid "Supply valid VIP password." +msgstr "Zadejte platné VIP heslo." -#: lib/osci/dialog/NewTaskDlg.py:356 -#: lib/osci/dialog/MainGameDlg.py:311 -msgid "Constr" -msgstr "Konstr." +#: lib/osci/dialog/NewAccountDlg.py:122 +msgid "Select starting position" +msgstr "Vyberte počáteční pozici" -#: lib/osci/dialog/NewTaskDlg.py:356 -#: lib/osci/dialog/ResearchDlg.py:323 -#: lib/osci/dialog/ResearchDlg.py:336 -#: lib/osci/dialog/ResearchDlg.py:350 -#: lib/osci/dialog/PlanetsOverviewDlg.py:264 -#: lib/osci/dialog/StarSystemDlg.py:1415 -msgid "ETC" -msgstr "ETC" +#: lib/osci/dialog/NewAccountDlg.py:128 +msgid "Galaxy" +msgstr "Galaxie" -#: lib/osci/dialog/NewTaskDlg.py:359 -msgid "Stucts" -msgstr "Budovy" +#: lib/osci/dialog/NewAccountDlg.py:128 +msgid "Position" +msgstr "Pozice" -#: lib/osci/dialog/NewTaskDlg.py:361 -#: lib/osci/dialog/FleetsAnalysisDlg.py:149 -msgid "Ships" -msgstr "Lodě" +#: lib/osci/dialog/NewAccountDlg.py:131 +msgid "VIP Password:" +msgstr "VIP Heslo:" -#: lib/osci/dialog/NewTaskDlg.py:363 -msgid "Misc" -msgstr "Různé" +#: lib/osci/dialog/NewAccountDlg.py:135 +msgid "Select" +msgstr "Vyber" -#: lib/osci/dialog/NewTaskDlg.py:365 -#: lib/osci/dialog/FleetCommandDlg.py:325 -#: lib/osci/dialog/StructTaskDlg.py:283 -msgid "1" -msgstr "1" +#: lib/osci/dialog/ChangeQtyDlg.py:53 +#: lib/osci/dialog/StructTaskDlg.py:226 +#: lib/osci/dialog/NewTaskDlg.py:285 +msgid "Specify quantity (1, 2, 3, ...)." +msgstr "Zadejte množství (1, 2, 3, ...)" -#: lib/osci/dialog/NewTaskDlg.py:367 -#: lib/osci/dialog/StructTaskDlg.py:285 -msgid "2" -msgstr "2" +#: lib/osci/dialog/ChangeQtyDlg.py:69 +msgid "Change quantity" +msgstr "Změnit množství" -#: lib/osci/dialog/NewTaskDlg.py:369 -#: lib/osci/dialog/StructTaskDlg.py:287 -msgid "3" -msgstr "3" +#: lib/osci/dialog/ChangeQtyDlg.py:77 +msgid "New quantity:" +msgstr "Nové množství:" -#: lib/osci/dialog/NewTaskDlg.py:371 -#: lib/osci/dialog/StructTaskDlg.py:289 -msgid "4" -msgstr "4" - -#: lib/osci/dialog/NewTaskDlg.py:373 -#: lib/osci/dialog/StructTaskDlg.py:291 -msgid "5" -msgstr "5" - -#: lib/osci/dialog/NewTaskDlg.py:375 -#: lib/osci/dialog/StructTaskDlg.py:293 -msgid "6" -msgstr "6" - -#: lib/osci/dialog/NewTaskDlg.py:377 -#: lib/osci/dialog/StructTaskDlg.py:295 -msgid "7" -msgstr "7" - -#: lib/osci/dialog/NewTaskDlg.py:379 -#: lib/osci/dialog/StructTaskDlg.py:297 -msgid "8" -msgstr "8" - -#: lib/osci/dialog/NewTaskDlg.py:381 -#: lib/osci/dialog/StructTaskDlg.py:299 -msgid "9" -msgstr "9" - -#: lib/osci/dialog/NewTaskDlg.py:386 -#: lib/osci/dialog/StarSystemDlg.py:1427 -msgid "Target planet" -msgstr "Cílová planeta" - -#: lib/osci/dialog/NewTaskDlg.py:389 -#: lib/osci/dialog/PlanetsOverviewDlg.py:251 -#: lib/osci/dialog/StarSystemDlg.py:1183 -msgid "Planet" -msgstr "Planeta" - -#: lib/osci/dialog/NewTaskDlg.py:389 -msgid "Owner" -msgstr "Vlastník" - -#: lib/osci/dialog/NewTaskDlg.py:392 -msgid "Target slots" -msgstr "Cílový slot" - -#: lib/osci/dialog/NewTaskDlg.py:395 -#: lib/osci/dialog/StructTaskDlg.py:302 -msgid "Bio production" -msgstr "Bio produkce" - -#: lib/osci/dialog/NewTaskDlg.py:397 -#: lib/osci/dialog/StructTaskDlg.py:304 -msgid "En production" -msgstr "Produkce energie" - -#: lib/osci/dialog/NewTaskDlg.py:399 -#: lib/osci/dialog/StructTaskDlg.py:306 -msgid "CP production" -msgstr "Produkce" - -#: lib/osci/dialog/NewTaskDlg.py:401 -#: lib/osci/dialog/StructTaskDlg.py:308 -msgid "RP production" -msgstr "Výzkum" - -#: lib/osci/dialog/NewTaskDlg.py:403 -#: lib/osci/dialog/NewTaskDlg.py:416 -#: lib/osci/dialog/StructTaskDlg.py:310 -msgid "Military" -msgstr "vojenská" - -#: lib/osci/dialog/NewTaskDlg.py:408 -#: lib/osci/dialog/FleetSpecsDlg.py:263 -msgid "Small" -msgstr "malá" - -#: lib/osci/dialog/NewTaskDlg.py:410 -#: lib/osci/dialog/FleetSpecsDlg.py:264 -msgid "Medium" -msgstr "střední" - -#: lib/osci/dialog/NewTaskDlg.py:412 -#: lib/osci/dialog/FleetSpecsDlg.py:265 -msgid "Large" -msgstr "velká" - -#: lib/osci/dialog/NewTaskDlg.py:414 -msgid "Civilian" -msgstr "civilní" - -#: lib/osci/dialog/NewTaskDlg.py:419 -#: lib/osci/dialog/StructTaskDlg.py:315 -#: lib/osci/dialog/OptionsDlg.py:432 -#: lib/osci/dialog/MainGameDlg.py:334 -#: lib/osci/dialog/LoginDlg.py:175 -msgid "Options" -msgstr "Nastavení" - -#: lib/osci/dialog/NewTaskDlg.py:421 -#: lib/osci/dialog/StructTaskDlg.py:317 -#: lib/osci/dialog/StarSystemDlg.py:1423 -#: lib/osci/dialog/StarSystemDlg.py:1447 -msgid "Quantity" -msgstr "Množství" - -#: lib/osci/dialog/NewTaskDlg.py:423 -#: lib/osci/dialog/StructTaskDlg.py:319 -#: lib/osci/dialog/OptionsDlg.py:524 -msgid "Report finalization" -msgstr "Hlásit dokončení" - -#: lib/osci/dialog/NewTaskDlg.py:425 -#: lib/osci/dialog/ConstrUpgradeDlg.py:139 -#: lib/osci/dialog/FleetSplitDlg.py:577 #: lib/osci/dialog/ChangeQtyDlg.py:87 -#: lib/osci/dialog/RenameSysDlg.py:114 -#: lib/osci/dialog/FleetCommandDlg.py:331 -#: lib/osci/dialog/BuoyDlg.py:126 +#: lib/osci/dialog/_Template.py:74 +#: lib/osci/dialog/FleetSplitDlg.py:590 #: lib/osci/dialog/GalaxyRestartDlg.py:92 -#: lib/osci/dialog/StructTaskDlg.py:323 -#: lib/osci/dialog/OptionsDlg.py:480 -#: lib/osci/dialog/OptionsDlg.py:506 -#: lib/osci/dialog/OptionsDlg.py:568 -#: lib/osci/dialog/ConstrSelTechDlg.py:179 -#: lib/osci/dialog/NewAccDlg.py:140 -#: lib/osci/dialog/NewMessageDlg.py:196 -#: lib/osci/dialog/NewMessageDlg.py:220 -#: lib/osci/dialog/FleetRedirectionDlg.py:125 +#: lib/osci/dialog/StructTaskDlg.py:355 +#: lib/osci/dialog/NewTaskDlg.py:427 #: lib/osci/dialog/RenameFleetDlg.py:139 -#: lib/osci/dialog/ColorDefinitionDlg.py:147 -#: lib/osci/dialog/_Template.py:74 -#: lib/osci/dialog/SearchDlg.py:119 +#: lib/osci/dialog/FleetRedirectionDlg.py:125 msgid "Cancel" msgstr "Storno" -#: lib/osci/dialog/NewTaskDlg.py:426 -#: lib/osci/dialog/ConstructionDlg.py:488 -msgid "Construct" -msgstr "Vyrobit" - -#: lib/osci/dialog/EventsDlg.py:110 -msgid "Executing DELETE MESSAGES command..." -msgstr "Vykonávám příkaz VYMAŽ ZPRÁVY..." - -#: lib/osci/dialog/EventsDlg.py:120 -msgid "Executing DELETE ALL MESSAGES command..." -msgstr "Vykonávám příkaz VYMAŽ VŠECHNY ZPRÁVY..." - -#: lib/osci/dialog/EventsDlg.py:177 -msgid "Time" -msgstr "Čas" - -#: lib/osci/dialog/EventsDlg.py:177 -msgid "Source" -msgstr "Zdroj" - -#: lib/osci/dialog/EventsDlg.py:178 -#: lib/osci/dialog/FleetsOverviewDlg.py:236 -msgid "Location" -msgstr "Místo" - -#: lib/osci/dialog/EventsDlg.py:178 -#: lib/osci/dialog/NewMessageDlg.py:189 -msgid "Message" -msgstr "Zpráva" - -#: lib/osci/dialog/EventsDlg.py:181 -#: lib/osci/dialog/EventsDlg.py:199 -#: lib/osci/dialog/MessagesDlg.py:399 -#: lib/osci/dialog/MessagesDlg.py:418 -msgid "Delete" -msgstr "Vymaž" - -#: lib/osci/dialog/EventsDlg.py:183 -#: lib/osci/dialog/FleetDlg.py:373 -msgid "Delete All" -msgstr "Vymaž vše" - -#: lib/osci/dialog/EventsDlg.py:185 -msgid "Minor msgs" -msgstr "Méně důležité zprávy" - -#: lib/osci/dialog/EventsDlg.py:187 -msgid "Info msgs" -msgstr "Informace" - -#: lib/osci/dialog/EventsDlg.py:193 -#: lib/osci/dialog/MessagesDlg.py:412 -msgid "Message actions" -msgstr "Zprávy" - -#: lib/osci/dialog/EventsDlg.py:195 -#: lib/osci/dialog/MessagesDlg.py:414 -msgid "Show location" -msgstr "Ukaž místo" - -#: lib/osci/dialog/EventsDlg.py:196 -#: lib/osci/dialog/MessagesDlg.py:415 -msgid "Show source" -msgstr "Ukaž zdroj" - -#: lib/osci/dialog/EventsDlg.py:197 -#: lib/osci/dialog/MessagesDlg.py:416 -msgid "Show location and delete msg" -msgstr "Jdi na místo a smaž zprávu" - -#: lib/osci/dialog/EventsDlg.py:198 -#: lib/osci/dialog/MessagesDlg.py:417 -msgid "Show source and delete msg" -msgstr "Ukaž zdroj a smaž zprávu" - -#: lib/osci/dialog/EmpireOverviewDlg.py:60 -msgid "No data available" -msgstr "Nedostupná data" - -#: lib/osci/dialog/EmpireOverviewDlg.py:69 -msgid "You are LEADER of the galaxy." -msgstr "Jsi VŮDCEM galaxie." - -#: lib/osci/dialog/EmpireOverviewDlg.py:72 -#: lib/osci/dialog/EmpireOverviewDlg.py:75 -msgid "You are IMPERATOR of the galaxy." -msgstr "Jsi IMPERÁTOREM galaxie." - -#: lib/osci/dialog/EmpireOverviewDlg.py:76 -msgid "You have the right to end this galaxy." -msgstr "Máš právo ukončit tuto galaxii." - -#: lib/osci/dialog/EmpireOverviewDlg.py:89 -msgid "Strategic resources:" -msgstr "Strategické zdroje:" - -#: lib/osci/dialog/EmpireOverviewDlg.py:114 -msgid "Statistics:" -msgstr "Statistiky:" - -#: lib/osci/dialog/EmpireOverviewDlg.py:115 -#: lib/osci/dialog/DiplomacyDlg.py:370 -#: lib/osci/dialog/StarSystemDlg.py:1250 -msgid "Population" -msgstr "Populace" - -#: lib/osci/dialog/EmpireOverviewDlg.py:117 -#: lib/osci/dialog/EmpireOverviewDlg.py:119 -msgid "Gov. power" -msgstr "Síla vlády" - -#: lib/osci/dialog/EmpireOverviewDlg.py:117 -msgid "unused" -msgstr "nevyužito" - -#: lib/osci/dialog/EmpireOverviewDlg.py:120 -#: lib/osci/dialog/EmpireOverviewDlg.py:280 -#: lib/osci/dialog/ProblemsDlg.py:442 -#: lib/osci/dialog/DiplomacyDlg.py:371 -#: lib/osci/dialog/MainGameDlg.py:313 -#: lib/osci/dialog/MainGameDlg.py:350 -msgid "Planets" -msgstr "Planety" - -#: lib/osci/dialog/EmpireOverviewDlg.py:122 -#: lib/osci/dialog/EmpireOverviewDlg.py:145 -#: lib/osci/dialog/EmpireOverviewDlg.py:173 -msgid "Raw production" -msgstr "Čistá produkce" - -#: lib/osci/dialog/EmpireOverviewDlg.py:123 -#: lib/osci/dialog/EmpireOverviewDlg.py:167 -msgid "Total production" -msgstr "Celková produkce" - -#: lib/osci/dialog/EmpireOverviewDlg.py:124 -msgid "Raw research" -msgstr "Čistý výzkum" - -#: lib/osci/dialog/EmpireOverviewDlg.py:125 -msgid "Total reseach" -msgstr "Celkem výzkum" - -#: lib/osci/dialog/EmpireOverviewDlg.py:126 -#: lib/osci/dialog/ConstructionDlg.py:461 -msgid "Military power" -msgstr "Vojenská síla" - -#: lib/osci/dialog/EmpireOverviewDlg.py:129 -msgid "Fame" -msgstr "Sláva" - -#: li... [truncated message content] |
From: <qa...@us...> - 2011-11-14 21:13:20
|
Revision: 319 http://ospace.svn.sourceforge.net/ospace/?rev=319&view=rev Author: qark Date: 2011-11-14 21:13:14 +0000 (Mon, 14 Nov 2011) Log Message: ----------- - Added support for different authentication schemes. Supported are PLAIN, MD5 (default), and SHA256. [Qark] Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/server/lib/ige/ClientMngr.py branches/ospace_0.5/server/lib/igeclient/IClient.py branches/ospace_0.5/server/run.py Added Paths: ----------- branches/ospace_0.5/server/lib/ige/Authentication.py Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2011-11-14 09:50:30 UTC (rev 318) +++ branches/ospace_0.5/ChangeLog.txt 2011-11-14 21:13:14 UTC (rev 319) @@ -8,6 +8,7 @@ [2011-11-14] - Fixed AI scripts deployment issues. [Qark] +- Added support for different authentication schemes. Supported are PLAIN, MD5 (default), and SHA256. [Qark] [2011-11-10] - run_ai.py can be restricted to selected galaxies. [Qark] Added: branches/ospace_0.5/server/lib/ige/Authentication.py =================================================================== --- branches/ospace_0.5/server/lib/ige/Authentication.py (rev 0) +++ branches/ospace_0.5/server/lib/ige/Authentication.py 2011-11-14 21:13:14 UTC (rev 319) @@ -0,0 +1,42 @@ +from ige import SecurityException +import hashlib +import time + +# default method is set to MD5 for backward compatibility +# with version 0.5.68 (revision 308) +defaultMethod = "md5" + +def getMethod(challenge): + return challenge.split(":")[0] + +def getWelcomeString(method = "md5"): + """Return welcome string (typically a challenge)""" + if method == "plain": + return "plain:" + elif method == "md5": + return "md5:" + hashlib.md5(str(time.time())).hexdigest() + elif method == "sha256": + return "sha256:" + hashlib.sha256(str(time.time())).hexdigest() + raise SecurityException("Unsupported authentication method %s" % str(method)) + +def encode(password, challenge): + """Encodes password using auth method specified in the challenge""" + method = getMethod(challenge) + if method == "plain": + return password + elif method == "md5": + return hashlib.md5(password + challenge).hexdigest() + elif method == "sha256": + return hashlib.sha256(password + challenge).hexdigest() + raise SecurityException("Unsupported authentication method %s" % str(method)) + +def verify(encodedPassword, password, challenge): + """Verifies password based on client encoded password and auth method""" + method = getMethod(challenge) + if method == "plain": + return encodedPassword == password + elif method == "md5": + return hashlib.md5(password + challenge).hexdigest() == encodedPassword + elif method == "sha256": + return hashlib.sha256(password + challenge).hexdigest() == encodedPassword + raise SecurityException("Unsupported authentication method %s" % str(method)) Property changes on: branches/ospace_0.5/server/lib/ige/Authentication.py ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: branches/ospace_0.5/server/lib/ige/ClientMngr.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ClientMngr.py 2011-11-14 09:50:30 UTC (rev 318) +++ branches/ospace_0.5/server/lib/ige/ClientMngr.py 2011-11-14 21:13:14 UTC (rev 319) @@ -25,6 +25,7 @@ import log from ige import SecurityException from ige.Const import ADMIN_LOGIN +import Authentication class Account: @@ -46,8 +47,11 @@ class ClientMngr: - def __init__(self, database, configDir): + def __init__(self, database, config, configDir): self.configDir = configDir + self.authMethod = config.server.authmethod + if not self.authMethod: + self.authMethod = Authentication.defaultMethod self._filename = os.path.join(self.configDir, 'accounts') self.sessions = {} # @@ -149,10 +153,10 @@ login = str(login) # create sort of cookie while 1: - sid = hashlib.md5(str(time.time())).hexdigest()[:8] + sid = hashlib.sha256(str(random.random())).hexdigest() if not self.sessions.has_key(sid): break - challenge = 'IGEServer@%f' % time.time() + challenge = Authentication.getWelcomeString(self.authMethod) session = Session(sid) session.challenge = challenge session.clientIdent = clientId @@ -173,7 +177,7 @@ account = self.accounts[login] challenge = self.sessions[sid].challenge - if hashlib.md5(account.passwd + challenge).hexdigest() != cpasswd: + if not Authentication.verify(cpasswd, account.passwd, challenge): raise SecurityException('Wrong login and/or password.') self.sessions[sid].setAttrs(account.login, account.nick, account.email) account.lastLogin = time.time() Modified: branches/ospace_0.5/server/lib/igeclient/IClient.py =================================================================== --- branches/ospace_0.5/server/lib/igeclient/IClient.py 2011-11-14 09:50:30 UTC (rev 318) +++ branches/ospace_0.5/server/lib/igeclient/IClient.py 2011-11-14 21:13:14 UTC (rev 319) @@ -18,8 +18,8 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -import hashlib import ige +import ige.Authentication from ige.IMarshal import IMarshal, IPacket from ige import ServerStatusException, log import httplib, urllib @@ -71,7 +71,7 @@ def login(self, gameID, login, password): self.gameID = gameID.encode("ascii") # hash password with challenge - passwd = hashlib.md5(password + self.challenge).hexdigest() + passwd = ige.Authentication.encode(password, self.challenge) #@log.debug(login, password, passwd) try: apply(IProxy('login', None, self), (login, passwd, self.hostID)) Modified: branches/ospace_0.5/server/run.py =================================================================== --- branches/ospace_0.5/server/run.py 2011-11-14 09:50:30 UTC (rev 318) +++ branches/ospace_0.5/server/run.py 2011-11-14 21:13:14 UTC (rev 319) @@ -165,6 +165,7 @@ # open database if config.server.dbbackend == "metakit": + # Legacy database backend log.message("Using metakit database backend") from ige.MetakitDatabase import Database, DatabaseString else: @@ -203,7 +204,7 @@ log.debug("Initializing issue manager") issueMngr = IssueMngr() log.debug("Initializing client manager") -clientMngr = ClientMngr(clientDB, options.configDir) +clientMngr = ClientMngr(clientDB, config, options.configDir) log.debug("Initializing message manager") msgMngr = MsgMngr(msgDB) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qa...@us...> - 2011-11-14 09:50:36
|
Revision: 318 http://ospace.svn.sourceforge.net/ospace/?rev=318&view=rev Author: qark Date: 2011-11-14 09:50:30 +0000 (Mon, 14 Nov 2011) Log Message: ----------- - Fixed AI scripts deployment issues. [Qark] Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/client-ai/ai_osc.py branches/ospace_0.5/server/run_ai.py Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2011-11-10 20:45:57 UTC (rev 317) +++ branches/ospace_0.5/ChangeLog.txt 2011-11-14 09:50:30 UTC (rev 318) @@ -6,6 +6,9 @@ - $Author$ - $Revision$ +[2011-11-14] +- Fixed AI scripts deployment issues. [Qark] + [2011-11-10] - run_ai.py can be restricted to selected galaxies. [Qark] - Added RPC call to commit all databases. [Qark] Modified: branches/ospace_0.5/client-ai/ai_osc.py =================================================================== --- branches/ospace_0.5/client-ai/ai_osc.py 2011-11-10 20:45:57 UTC (rev 317) +++ branches/ospace_0.5/client-ai/ai_osc.py 2011-11-14 09:50:30 UTC (rev 318) @@ -24,12 +24,15 @@ import sys import os -sys.path.insert(0, "../client-pygame/lib") -sys.path.insert(0, "../client-pygame/lib/osci") +basepath = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -for item in ("libsrvr", "../server/lib"): - if os.path.exists(item): - sys.path.insert(0, item) +sys.path.insert(0, os.path.join(basepath, "client-pygame/lib")) +sys.path.insert(0, os.path.join(basepath, "client-pygame/lib/osci")) + +for item in ("libsrvr", "server/lib"): + path = os.path.join(basepath, item) + if os.path.exists(path): + sys.path.insert(0, path) break #configure gc Modified: branches/ospace_0.5/server/run_ai.py =================================================================== --- branches/ospace_0.5/server/run_ai.py 2011-11-10 20:45:57 UTC (rev 317) +++ branches/ospace_0.5/server/run_ai.py 2011-11-14 09:50:30 UTC (rev 318) @@ -107,10 +107,14 @@ return -sys.path.insert(0,"../client-ai") -for item in ("libsrvr", "../server/lib"): - if os.path.exists(item): - sys.path.insert(0, item) +basepath = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +sys.path.insert(0, os.path.join(basepath, "client-ai")) + +for item in ("libsrvr", "server/lib"): + path = os.path.join(basepath, item) + if os.path.exists(path): + sys.path.insert(0, path) break from ai_parser import AIList @@ -150,10 +154,10 @@ for login, (password, ais, galaxy) in aiList.getAll(): if options.galaxies and galaxy not in options.galaxies: continue - args = shlex.split('python ../client-ai/ai_osc.py --configdir=%s --server=%s --login=%s --password=%s --ai=%s' %\ - (os.path.join(options.configDir, 'ai_data', galaxy), options.server, login, password, ais)) + args = shlex.split('python %s/client-ai/ai_osc.py --configdir=%s --server=%s --login=%s --password=%s --ai=%s' %\ + (basepath, os.path.join(options.configDir, 'ai_data', galaxy), options.server, login, password, ais)) procQueue.addProc(args) # os.system('python ../client-ai/ai_osc.py --configdir=%s --server=%s --login=%s --password=%s --ai=%s' %\ # (options.configDir, options.server, login, password, ais)) procQueue.waitForEnd() -sys.exit() \ No newline at end of file +sys.exit() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qa...@us...> - 2011-11-10 20:46:04
|
Revision: 317 http://ospace.svn.sourceforge.net/ospace/?rev=317&view=rev Author: qark Date: 2011-11-10 20:45:57 +0000 (Thu, 10 Nov 2011) Log Message: ----------- - Added RPC call to commit all databases. [Qark] - Extended resignation period. [Qark] - System names file location is now relative. [Qark] Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/server/lib/ige/ClientMngr.py branches/ospace_0.5/server/lib/ige/GameMngr.py branches/ospace_0.5/server/lib/ige/RPCServer.py branches/ospace_0.5/server/lib/ige/ospace/GalaxyGenerator.py branches/ospace_0.5/server/lib/ige/ospace/Rules/__init__.py branches/ospace_0.5/server/lib/igeclient/IClient.py Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2011-11-10 20:36:53 UTC (rev 316) +++ branches/ospace_0.5/ChangeLog.txt 2011-11-10 20:45:57 UTC (rev 317) @@ -8,6 +8,9 @@ [2011-11-10] - run_ai.py can be restricted to selected galaxies. [Qark] +- Added RPC call to commit all databases. [Qark] +- Extended resignation period. [Qark] +- System names file location is now relative. [Qark] [2011-11-07] - Galaxy booking system now generates galaxies with random placement. [dahaic] Modified: branches/ospace_0.5/server/lib/ige/ClientMngr.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ClientMngr.py 2011-11-10 20:36:53 UTC (rev 316) +++ branches/ospace_0.5/server/lib/ige/ClientMngr.py 2011-11-10 20:45:57 UTC (rev 317) @@ -240,7 +240,7 @@ deleted = 0 for id in self.sessions.keys(): if self.sessions[id].timeout < now: - log.debug("Deleting session", sessions[id].sid, getattr(sessions[id], "login", "<unknown>")) + log.debug("Deleting session", self.sessions[id].sid, getattr(self.sessions[id], "login", "<unknown>")) del self.sessions[id] deleted += 1 log.debug('cleanup finished (%d active, %d deleted)' % (len(self.sessions), deleted)) Modified: branches/ospace_0.5/server/lib/ige/GameMngr.py =================================================================== --- branches/ospace_0.5/server/lib/ige/GameMngr.py 2011-11-10 20:36:53 UTC (rev 316) +++ branches/ospace_0.5/server/lib/ige/GameMngr.py 2011-11-10 20:45:57 UTC (rev 317) @@ -221,6 +221,15 @@ aiList.backup(basename) return True, None + def commitDatabases(self, sid): + session = self.clientMngr.getSession(sid) + if session.login != ADMIN_LOGIN: + raise SecurityException('You cannot issue this command.') + self.db.checkpoint() + self.clientMngr.checkpoint() + self.msgMngr.checkpoint() + return True, None + def createAdmin(self): """ Return Player object which will act as administrator of the game.""" raise NotImplementedError Modified: branches/ospace_0.5/server/lib/ige/RPCServer.py =================================================================== --- branches/ospace_0.5/server/lib/ige/RPCServer.py 2011-11-10 20:36:53 UTC (rev 316) +++ branches/ospace_0.5/server/lib/ige/RPCServer.py 2011-11-10 20:45:57 UTC (rev 317) @@ -172,6 +172,7 @@ callMap[game.gameID + '.turnFinished'] = game.turnFinished callMap[game.gameID + '.processTurn'] = game.processTurn callMap[game.gameID + '.backup'] = game.backup + callMap[game.gameID + '.commitDatabases'] = game.commitDatabases def xmlrpcPublish(name, obj): objMap[name] = obj Modified: branches/ospace_0.5/server/lib/ige/ospace/GalaxyGenerator.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/GalaxyGenerator.py 2011-11-10 20:36:53 UTC (rev 316) +++ branches/ospace_0.5/server/lib/ige/ospace/GalaxyGenerator.py 2011-11-10 20:45:57 UTC (rev 317) @@ -18,7 +18,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -import random, math, sys +import os, random, math, sys class GalaxyStats: @@ -752,7 +752,16 @@ def loadSystemNames(): global systemNames names = {} - for line in file('data/SystemNames.txt'): + filename = os.path.join( + os.path.dirname(__file__), + "..", + "..", + "..", + "data", + "SystemNames.txt", + ) + filename = os.path.abspath(filename) + for line in open(filename, "r"): names[line.strip()] = None systemNames = names.keys() Modified: branches/ospace_0.5/server/lib/ige/ospace/Rules/__init__.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/Rules/__init__.py 2011-11-10 20:36:53 UTC (rev 316) +++ branches/ospace_0.5/server/lib/ige/ospace/Rules/__init__.py 2011-11-10 20:45:57 UTC (rev 317) @@ -27,8 +27,8 @@ ## General turnsPerDay = 24 rotationMod = 384.0 -playerTimeout = 60 * 60 * 24 * 21 # 21 days -novicePlayerTimeout = 60 * 60 * 24 * 7 # 7 days +playerTimeout = 60 * 60 * 24 * 28 # 28 days +novicePlayerTimeout = 60 * 60 * 24 * 14 # 14 days messageTimeout = 60 * 60 * 24 * 14 # 14 days ## New player @@ -48,7 +48,7 @@ envInterval = 1000 envAutoMod = 10.0 envMax = 200 -envSelfUpgradeChance = {"H": 5, "C": 1, "B": 500, "m": 100} # in ten thousandths (10 000) +envSelfUpgradeChance = {"H": 5, "C": 1, "B": 500, "m": 100, "r": 100, "p": 100, "e": 100} # in ten thousandths (10 000) planetSpec = {} planetSpec[u'A'] = makeIDataHolder( minBio = 0, Modified: branches/ospace_0.5/server/lib/igeclient/IClient.py =================================================================== --- branches/ospace_0.5/server/lib/igeclient/IClient.py 2011-11-10 20:36:53 UTC (rev 316) +++ branches/ospace_0.5/server/lib/igeclient/IClient.py 2011-11-10 20:45:57 UTC (rev 317) @@ -134,6 +134,9 @@ def backup(self, basename): return apply(IProxy('%s.backup' % self.gameID, None, self), (basename,)) + def commitDatabases(self): + return apply(IProxy('%s.commitDatabases' % self.gameID, None, self), ()) + def getTurnData(self): return apply(IProxy('%s.getTurnData' % self.gameID, None, self), ()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qa...@us...> - 2011-11-10 20:37:00
|
Revision: 316 http://ospace.svn.sourceforge.net/ospace/?rev=316&view=rev Author: qark Date: 2011-11-10 20:36:53 +0000 (Thu, 10 Nov 2011) Log Message: ----------- run_ai.py can be restricted to selected galaxies. Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/server/run_ai.py Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2011-11-07 17:19:42 UTC (rev 315) +++ branches/ospace_0.5/ChangeLog.txt 2011-11-10 20:36:53 UTC (rev 316) @@ -6,6 +6,9 @@ - $Author$ - $Revision$ +[2011-11-10] +- run_ai.py can be restricted to selected galaxies. [Qark] + [2011-11-07] - Galaxy booking system now generates galaxies with random placement. [dahaic] Modified: branches/ospace_0.5/server/run_ai.py =================================================================== --- branches/ospace_0.5/server/run_ai.py 2011-11-07 17:19:42 UTC (rev 315) +++ branches/ospace_0.5/server/run_ai.py 2011-11-10 20:36:53 UTC (rev 316) @@ -132,6 +132,12 @@ default = "1", help = "Maximum number of concurrent processes" ) +parser.add_option("", "--galaxy", dest = "galaxies", + metavar = "NAME", + action = "append", + default = [], + help = "Name of galaxy to enable AI for" +) options, args = parser.parse_args() @@ -142,6 +148,8 @@ procs = [] procQueue = ProcQueue(int(options.procs)) for login, (password, ais, galaxy) in aiList.getAll(): + if options.galaxies and galaxy not in options.galaxies: + continue args = shlex.split('python ../client-ai/ai_osc.py --configdir=%s --server=%s --login=%s --password=%s --ai=%s' %\ (os.path.join(options.configDir, 'ai_data', galaxy), options.server, login, password, ais)) procQueue.addProc(args) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <da...@us...> - 2011-11-07 17:19:49
|
Revision: 315 http://ospace.svn.sourceforge.net/ospace/?rev=315&view=rev Author: dahaic Date: 2011-11-07 17:19:42 +0000 (Mon, 07 Nov 2011) Log Message: ----------- - Galaxy booking system now generates galaxies with random placement. [dahaic] Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/server/lib/ige/ospace/GalaxyGenerator.py branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py branches/ospace_0.5/server/run_galaxer.py Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2011-11-06 13:17:56 UTC (rev 314) +++ branches/ospace_0.5/ChangeLog.txt 2011-11-07 17:19:42 UTC (rev 315) @@ -6,6 +6,9 @@ - $Author$ - $Revision$ +[2011-11-07] +- Galaxy booking system now generates galaxies with random placement. [dahaic] + [2011-11-06] - Mutant may, from now on, deploy on a free planets of the system owned by someone else. [dahaic] - AI from now on checks, whether the build jobs target a non-other-player planets (ie. no more building on neighbours planets) [dahaic] Modified: branches/ospace_0.5/server/lib/ige/ospace/GalaxyGenerator.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/GalaxyGenerator.py 2011-11-06 13:17:56 UTC (rev 314) +++ branches/ospace_0.5/server/lib/ige/ospace/GalaxyGenerator.py 2011-11-07 17:19:42 UTC (rev 315) @@ -158,8 +158,8 @@ class GalaxyGenerator: def __init__(self): - self.galaxyTypes = {'Circle9P':(9, 'Smaller galaxy for 9 players, without pirate or EDEN. Recommended for new players or those who seek more casual gameplay.'), - 'Circle42P':(42, 'Original size galaxy for 42 players, place of epic battles, recommended only to the experienced players. May be quite time consuming.')} + self.galaxyTypes = {'Circle9P':(9, 'Smaller galaxy for 9 players, without pirate or EDEN. Recommended for new players or those who seek more casual gameplay.', 26.0), + 'Circle42P':(42, 'Original size galaxy for 42 players, place of epic battles, recommended only to the experienced players. May be quite time consuming.', 50.0)} def generateGalaxy(self, galaxyType, fileHandle): if not galaxyType in self.galaxyTypes.keys(): Modified: branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py 2011-11-06 13:17:56 UTC (rev 314) +++ branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py 2011-11-07 17:19:42 UTC (rev 315) @@ -411,6 +411,7 @@ getReferences.public = 0 + # TODO remove it as soon as having a standalone galaxy generator def getPossibleGalaxyTypes(self, tran, obj): galGen = GalaxyGenerator.GalaxyGenerator() return galGen.getGalaxyTypes() Modified: branches/ospace_0.5/server/run_galaxer.py =================================================================== --- branches/ospace_0.5/server/run_galaxer.py 2011-11-06 13:17:56 UTC (rev 314) +++ branches/ospace_0.5/server/run_galaxer.py 2011-11-07 17:19:42 UTC (rev 315) @@ -19,8 +19,10 @@ # import atexit +import math import optparse import os +import random import sys import time import xmlrpclib @@ -106,7 +108,7 @@ if session: playerNick = session.nick for galType in types: - playerCapacity, infoText = types[galType] + playerCapacity, infoText, radius = types[galType] query = db.execute('SELECT COUNT(*), galType\ FROM players GROUP BY galType\ HAVING galType=?', (galType,)).fetchone() @@ -136,27 +138,31 @@ GROUP BY galType', ()).fetchall() types = s.getPossibleGalaxyTypes(OID_UNIVERSE) for galType, count in query: - galCap, galInfo = types[galType] - if galCap * options.threshold <= count: - # - return createNewGalaxy(galType, galCap) + galCap, galInfo, radius = types[galType] + if galCap * options.threshold <= count: + return createNewGalaxy(galType, galCap, radius) -def createNewGalaxy(galType, galCap): +def createNewGalaxy(galType, galCap, radius): actualGalaxies = _getActualGalaxies() - galPositions = set([]) + # using sqlite to provide rtree, as it is part of the standard library + tempdb = sqlite3.connect(':memory:') + tempdb.execute('CREATE VIRTUAL TABLE galaxies_positions USING rtree(id INTEGER PRIMARY KEY, x_min, x_max, y_min, y_max)') galNames = set([]) - maxCoordinate = 0 - names = ['Argo', 'Beidos', 'Ceelia', 'Daela', 'Everen', 'Ferun', 'Garis', 'Hiron', 'Inera', 'Jinx', 'Kelenor', 'Larion', 'Merlis'] + maxRadius = radius + # reserve is half of the minimal range of the galaxies + reserve = 50.0 + galRadius = radius + reserve + # fill list of possible galaxy names + names = [] + for name in open('data/GalaxyNames.txt'): + names.append(name.strip()) for galaxyID in actualGalaxies: galName, galX, galY, galRadius = actualGalaxies[galaxyID] - galX = int(galX) - galY = int(galY) - galRadius = int(galRadius) + maxRadius = max(maxRadius, galRadius) + galRadius += reserve galNames.add(galName) - galPositions.add((galX, galY)) - maxCoordinate = max(maxCoordinate, galX, galY) - if galRadius > 50 or galX % 100 or galY % 100: - raise NotImplementedError + tempdb.execute('INSERT INTO galaxies_positions VALUES (?, ?, ?, ?, ?)', + (galaxyID, galX-galRadius, galX+galRadius, galY-galRadius, galY+galRadius)) # get list of booked players, and delete # their records from the booking system query = db.execute('SELECT login, nick, email FROM players\ @@ -170,21 +176,21 @@ WHERE nick=?', (nick,)) # now we need to find the place for it - squareSide = maxCoordinate / 200 + 1 - if squareSide**2 == len(actualGalaxies): - squareSide += 1 - hasFound = False - for y in xrange(squareSide): - posY = y * 200 + 100 - for x in xrange(squareSide): - posX = x * 200 + 100 - if (posX, posY) in galPositions: - continue - hasFound = True - if hasFound: - break - if hasFound: - break + search = True + # we don't want to have negative coordinates + lowLimit = int(math.ceil(radius)) + # surface of biggest galaxy is multiplied by number of galaxies to get + # filled surface. By adding the surface of new galaxy, we get the surface of + # hypothetical square. 4.4 is magic constant that multiply length of side to + # ensure that the new galaxy will fit in all cases (actually 4.3 should be + # sufficient according to 10000 run Monte Carlo simulation) + highLimit = int(math.ceil(((maxRadius ** 2 ) * len(actualGalaxies) + galRadius ** 2) ** 0.5 * 4.4 + radius)) + while search: + posX = random.randrange(lowLimit, highLimit) + posY = random.randrange(lowLimit, highLimit) + search = bool(tempdb.execute('SELECT id FROM galaxies_positions WHERE\ + x_min<? AND x_max>? AND y_min<? AND y_max>?', + (posX+galRadius, posX-galRadius, posY+galRadius, posY-galRadius)).fetchall()) # searching for free name for the galaxy nameFound = False for name in names: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <da...@us...> - 2011-11-06 13:18:02
|
Revision: 314 http://ospace.svn.sourceforge.net/ospace/?rev=314&view=rev Author: dahaic Date: 2011-11-06 13:17:56 +0000 (Sun, 06 Nov 2011) Log Message: ----------- - Mutant may, from now on, deploy on a free planets of the system owned by someone else. [dahaic] - AI from now on checks, whether the build jobs target a non-other-player planets (ie. no more building on neighbours planets) [dahaic] - Mutant minefield now correctly show the information. [dahaic] - Bug in TechInfoDlg when no information for particular building was available. [dahaic] - Added import pygame._view for better support of py2exe. [dahaic] - Fixed statistics of Generator Complex [Tiamat] - Fix of the ChangeLog :) Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/client-ai/AIs/ais_mutant.py branches/ospace_0.5/client-ai/ai_tools.py branches/ospace_0.5/client-pygame/lib/osci/dialog/TechInfoDlg.py branches/ospace_0.5/server/lib/ige/ospace/GalaxyGenerator.py branches/ospace_0.5/server/lib/ige/ospace/Rules/Setup.xml branches/ospace_0.5/server/lib/ige/ospace/Rules/TL5.xml Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2011-10-31 00:47:19 UTC (rev 313) +++ branches/ospace_0.5/ChangeLog.txt 2011-11-06 13:17:56 UTC (rev 314) @@ -6,11 +6,18 @@ - $Author$ - $Revision$ -VERSION 0.5.68 +[2011-11-06] +- Mutant may, from now on, deploy on a free planets of the system owned by someone else. [dahaic] +- AI from now on checks, whether the build jobs target a non-other-player planets (ie. no more building on neighbours planets) [dahaic] +- Mutant minefield now correctly show the information. [dahaic] +- Bug in TechInfoDlg when no information for particular building was available. [dahaic] +- Added import pygame._view for better support of py2exe. [dahaic] +- Fixed statistics of Generator Complex [Tiamat] +- Fix of the ChangeLog :) [2011-10-31] -- Players lose their bookings when joining a galaxy. -- Fixed few things made in the last revision. +- From now on, players lose their bookings when joining a galaxy. [dahaic] +- Fixed few things made in the last revision. [dahaic] [2011-10-30] - First implementation of galaxy booking system (named Galaxer) [dahaic] @@ -26,6 +33,8 @@ [2011-10-21] - Fixed shields being recharged just in case of hull damage. [dahaic] +VERSION 0.5.68 + [2011-08-16] - Server startup script can be run from a different directory now. [Qark] Modified: branches/ospace_0.5/client-ai/AIs/ais_mutant.py =================================================================== --- branches/ospace_0.5/client-ai/AIs/ais_mutant.py 2011-10-31 00:47:19 UTC (rev 313) +++ branches/ospace_0.5/client-ai/AIs/ais_mutant.py 2011-11-06 13:17:56 UTC (rev 314) @@ -138,7 +138,7 @@ if not hasSeeders or not hasSeekers: # 20 % if shipDraw < 3: - planet.prodQueue, player.stratRes = client.cmdProxy.startConstruction(planetID, 1, 3, planetID, True, False, OID_NONE) + planet.prodQueue, player.stratRes = client.cmdProxy.startConstruction(planetID, 1, 2, planetID, True, False, OID_NONE) else: if not hasSeeders: planet.prodQueue, player.stratRes = client.cmdProxy.startConstruction(planetID, 2, 1, planetID, True, False, OID_NONE) @@ -190,7 +190,7 @@ if noOfSlots < planet.plSlots: noOfSlots = planet.plSlots biggestPlanet = planetID - # send the fleet + # send the fleet fleet, newFleet, myFleets = orderPartFleet(client, db, {2:1}, True, fleetID, FLACTION_DEPLOY, biggestPlanet, 2) data.myFleetSheets[fleetID][2] -= 1 @@ -200,6 +200,28 @@ else: shouldRepeat = True data.freeSystems.remove(systemID) + # if there is no free system to go to, does the ship levitate over + # the system partly occupied by someone else, and partly free? + else: + fleet = db[fleetID] + orbitingID = fleet.orbiting + if not orbitingID == OID_NONE: + orbiting = db[orbitingID] + if set(orbiting.planets) & data.freePlanets and orbitingID in data.otherSystems: + noOfSlots = 0 + biggestPlanet = None + for planetID in set(orbiting.planets) & data.freePlanets: + planet = db[planetID] + if noOfSlots < planet.plSlots: + noOfSlots = planet.plSlots + biggestPlanet = planetID + # issue the deploy order + fleet, newFleet, myFleets = orderPartFleet(client, db, + {2:1}, True, fleetID, FLACTION_DEPLOY, biggestPlanet, 2) + data.myFleetSheets[fleetID][2] -= 1 + if data.myFleetSheets[fleetID][2] == 0: + del data.myFleetSheets[fleetID][2] + seederFleets.remove(fleetID) def shipDesignManager(): Modified: branches/ospace_0.5/client-ai/ai_tools.py =================================================================== --- branches/ospace_0.5/client-ai/ai_tools.py 2011-10-31 00:47:19 UTC (rev 313) +++ branches/ospace_0.5/client-ai/ai_tools.py 2011-11-06 13:17:56 UTC (rev 314) @@ -222,7 +222,7 @@ def findInfluence(client, db, rangeOfInfluence, objectIDList): """ Returns list of all systems, which distance to any object - from the objectList is lesser than rangeOfInfluence. + from the objectList is less than rangeOfInfluence. objectList -- iterable of IDs, and each of the objects in the db has to have .x and .y numeric parameters. @@ -670,6 +670,20 @@ deltaBio -= tech.prodBio * Rules.techImprEff[player.techs.get(techID, 1)] * sum([x*y/100.0 for x, y in zip(tech.prodBioMod, [planet.plBio, planet.plMin, planet.plEn, 100])]) deltaProd -= tech.prodProd * Rules.techImprEff[player.techs.get(techID, 1)] * sum([x*y/100.0 for x, y in zip(tech.prodProdMod, [planet.plBio, planet.plMin, planet.plEn, 100])]) return deltaBio, deltaEn, deltaProd + +def checkBuildQueues(client, db, systemID, prodPlanets): + system = db[systemID] + player = client.getPlayer() + for planetID in prodPlanets: + planet = db[planetID] + validTasks = 0 + while len(planet.prodQueue) > validTasks: + # validTasks is effectively the actual index + task = planet.prodQueue[validTasks] + if task.targetID in data.myPlanets | data.freePlanets | set([OID_NONE, None]): + validTasks += 1 + else: + planet.prodQueue, player.stratRes = client.cmdProxy.abortConstruction(planetID, validTasks) def buildSystem(client, db, systemID, prodPlanets, finalSystemPlan): """ Assigns tasks to all idle planets with CP > 0 in one system, according @@ -691,6 +705,7 @@ structsToBuild = {} structsToDemolish = {} difference = {} + checkBuildQueues(client, db, systemID, prodPlanets) # parse final plan to set buildings which need to be build and those that # may be demolished for planetID in finalSystemPlan: Modified: branches/ospace_0.5/client-pygame/lib/osci/dialog/TechInfoDlg.py =================================================================== --- branches/ospace_0.5/client-pygame/lib/osci/dialog/TechInfoDlg.py 2011-10-31 00:47:19 UTC (rev 313) +++ branches/ospace_0.5/client-pygame/lib/osci/dialog/TechInfoDlg.py 2011-11-06 13:17:56 UTC (rev 314) @@ -311,6 +311,8 @@ descr.append(_('Rumours:')) descr.extend(tech.textFlavor.split('\n')) descr.append('') + if not len(descr): + descr.append(_('No information available')) # self.win.vDescr.text = descr # re-set techType if neccessary Modified: branches/ospace_0.5/server/lib/ige/ospace/GalaxyGenerator.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/GalaxyGenerator.py 2011-10-31 00:47:19 UTC (rev 313) +++ branches/ospace_0.5/server/lib/ige/ospace/GalaxyGenerator.py 2011-11-06 13:17:56 UTC (rev 314) @@ -36,10 +36,10 @@ self.galaxyMinPlanets = 0 self.galaxyMaxPlanets = 99999 self.galaxyCenter = (20.0, 20.0) - self.galaxyRadius = 20.0 + self.galaxyRadius = 15.0 self.galaxyStartR = (14.0, 16.0) self.galaxyPlayers = 4 - self.galaxyPlayerGroup = 1 + self.galaxyPlayerGroup = 4 self.galaxyGroupDist = 1 self.galaxyMinR = 5 self.galaxyDensity = {5: 3, 10: 3.5, 20: 4} Modified: branches/ospace_0.5/server/lib/ige/ospace/Rules/Setup.xml =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/Rules/Setup.xml 2011-10-31 00:47:19 UTC (rev 313) +++ branches/ospace_0.5/server/lib/ige/ospace/Rules/Setup.xml 2011-11-06 13:17:56 UTC (rev 314) @@ -317,6 +317,7 @@ minenum="15" minerate="6" isMilitary="1" + fullInfo="1" /> </technology> <technology id="9077" symbol="MUTANTBASE4" name="Mutant Junction"> Modified: branches/ospace_0.5/server/lib/ige/ospace/Rules/TL5.xml =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/Rules/TL5.xml 2011-10-31 00:47:19 UTC (rev 313) +++ branches/ospace_0.5/server/lib/ige/ospace/Rules/TL5.xml 2011-11-06 13:17:56 UTC (rev 314) @@ -180,11 +180,11 @@ buildSRes="SR_TL5C" operWorkers="2000" moraleTrgt="+8" - prodBio="300" - prodBioMod="0.6,0.0,0.6,0.3" + prodBio="450" + prodBioMod="0.4,0.0,0.4,0.2" storBio="4800" - prodEn="500" - prodEnMod="0.6,0.0,0.6,0.3" + prodEn="750" + prodEnMod="0.4,0.0,0.4,0.2" storEn="6000" maxHP="800" prodEnv="+16" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <da...@us...> - 2011-10-31 00:47:29
|
Revision: 313 http://ospace.svn.sourceforge.net/ospace/?rev=313&view=rev Author: dahaic Date: 2011-10-31 00:47:19 +0000 (Mon, 31 Oct 2011) Log Message: ----------- - Players lose their bookings when joining a galaxy. - Fixed few things made in the last revision. Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py branches/ospace_0.5/server/run_galaxer.py Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2011-10-30 22:09:37 UTC (rev 312) +++ branches/ospace_0.5/ChangeLog.txt 2011-10-31 00:47:19 UTC (rev 313) @@ -8,6 +8,10 @@ VERSION 0.5.68 +[2011-10-31] +- Players lose their bookings when joining a galaxy. +- Fixed few things made in the last revision. + [2011-10-30] - First implementation of galaxy booking system (named Galaxer) [dahaic] - players may book the galaxy type of their choice, and it will create it Modified: branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py 2011-10-30 22:09:37 UTC (rev 312) +++ branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py 2011-10-31 00:47:19 UTC (rev 313) @@ -359,13 +359,13 @@ def createNewPlayer(self, sid, galaxyID): log.debug('Creating new player in session', sid) session = self.clientMngr.getSession(sid) - self._createNewPlayer(session, galaxyID) + return self._createNewPlayer(session, galaxyID) def createNewSubscribedPlayer(self, (login, nick, email), galaxyID): log.debug('Creating new subscribed player using fake session') session = Session(None) session.setAttrs(login, nick, email) - self._createNewPlayer(session, galaxyID) + return self._createNewPlayer(session, galaxyID) def removePlayer(self, playerID): log.debug('removePlayer', playerID) Modified: branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py 2011-10-30 22:09:37 UTC (rev 312) +++ branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py 2011-10-31 00:47:19 UTC (rev 313) @@ -417,6 +417,17 @@ getPossibleGalaxyTypes.public = 1 getPossibleGalaxyTypes.accLevel = AL_ADMIN + + def getActivePlayers(self, tran, obj): + playerNames = [] + for playerID in obj.players: + player = tran.db[playerID] + if not player.type in AI_PLAYER_TYPES: + playerNames.append(player.name) + return playerNames + + getActivePlayers.public = 1 + getActivePlayers.accLevel = AL_ADMIN def getPublicInfo(self, tran, obj): result = IDataHolder() Modified: branches/ospace_0.5/server/run_galaxer.py =================================================================== --- branches/ospace_0.5/server/run_galaxer.py 2011-10-30 22:09:37 UTC (rev 312) +++ branches/ospace_0.5/server/run_galaxer.py 2011-10-31 00:47:19 UTC (rev 313) @@ -59,13 +59,19 @@ return galaxies def _getActivePlayers(): - un = s.getInfo(OID_UNIVERSE) - players = [] - for playerID in un.players: - player = s.getInfo(playerID) - if not player.type in Const.AI_PLAYER_TYPES: - players.append(player.name) - return players + return s.getActivePlayers(OID_UNIVERSE) + +def _removePlayingPlayers(): + activePlayers = _getActivePlayers() + query = db.execute('SELECT DISTINCT nick FROM players', ()).fetchall() + bookingPlayers = [] + for (nick,) in query: + bookingPlayers.append(nick) + zombiePlayers = set(bookingPlayers) & set(activePlayers) + for nick in zombiePlayers: + db.execute('DELETE FROM players\ + WHERE nick=?', + (nick,)) def setPlayerPreference(token, galType): global db @@ -125,13 +131,14 @@ def testBooking(): global db - modifier = 1 + _removePlayingPlayers() query = db.execute('SELECT galType, COUNT(*) FROM players\ GROUP BY galType', ()).fetchall() types = s.getPossibleGalaxyTypes(OID_UNIVERSE) for galType, count in query: galCap, galInfo = types[galType] - if galCap * modifier <= count: + if galCap * options.threshold <= count: + # return createNewGalaxy(galType, galCap) def createNewGalaxy(galType, galCap): @@ -240,14 +247,20 @@ ) parser.add_option("", "--OSserver", dest = "server", metavar = "HOSTNAME:PORT", - default = "localhost:9080", + default = "www.ospace.net:9080", help = "Outer Space server location" ) parser.add_option("", "--address", dest = "address", metavar = "HOSTNAME:PORT", - default = "localhost:9081", + default = "www.ospace.net:9081", help = "Outer Space galaxer location" ) +parser.add_option("", "--threshold", dest = "threshold", + metavar = "REALNUMBER", + default = 1.0, + type = "float", + help = "Ratio of galaxy capacity, which is necessary to create it." +) options, args = parser.parse_args() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <da...@us...> - 2011-10-30 22:09:44
|
Revision: 312 http://ospace.svn.sourceforge.net/ospace/?rev=312&view=rev Author: dahaic Date: 2011-10-30 22:09:37 +0000 (Sun, 30 Oct 2011) Log Message: ----------- - First implementation of galaxy booking system (named Galaxer) [dahaic] - players may book the galaxy type of their choice, and it will create it as soon as there is enough willing to play. In that case, it will auto join all the subscribers into it - galaxies created by galaxer doesn't restart, only ends - galaxies created by galaxer has 2 days of forced time freeze period Modified Paths: -------------- branches/ospace_0.5/ChangeLog.txt branches/ospace_0.5/client-pygame/lib/osci/client.py branches/ospace_0.5/client-pygame/lib/osci/dialog/NewAccountDlg.py branches/ospace_0.5/client-pygame/lib/osci/main.py branches/ospace_0.5/server/lib/ige/ClientMngr.py branches/ospace_0.5/server/lib/ige/LimitedClientMngr.py branches/ospace_0.5/server/lib/ige/RPCServer.py branches/ospace_0.5/server/lib/ige/ospace/GalaxyGenerator.py branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py branches/ospace_0.5/server/lib/ige/ospace/IGalaxy.py branches/ospace_0.5/server/lib/ige/ospace/IPlanet.py branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py branches/ospace_0.5/server/lib/igeclient/IClient.py Added Paths: ----------- branches/ospace_0.5/client-pygame/lib/osci/dialog/GalaxerDlg.py branches/ospace_0.5/server/run_galaxer.py Modified: branches/ospace_0.5/ChangeLog.txt =================================================================== --- branches/ospace_0.5/ChangeLog.txt 2011-10-23 16:23:20 UTC (rev 311) +++ branches/ospace_0.5/ChangeLog.txt 2011-10-30 22:09:37 UTC (rev 312) @@ -8,6 +8,14 @@ VERSION 0.5.68 +[2011-10-30] +- First implementation of galaxy booking system (named Galaxer) [dahaic] + - players may book the galaxy type of their choice, and it will create it + as soon as there is enough willing to play. In that case, it will auto + join all the subscribers into it + - galaxies created by galaxer doesn't restart, only ends + - galaxies created by galaxer has 2 days of forced time freeze period + [2011-10-23] - Fixed bug in 'Problems' dialog, global queues were reported as empty when all assigned planets had 0 production. [dahaic] Modified: branches/ospace_0.5/client-pygame/lib/osci/client.py =================================================================== --- branches/ospace_0.5/client-pygame/lib/osci/client.py 2011-10-23 16:23:20 UTC (rev 311) +++ branches/ospace_0.5/client-pygame/lib/osci/client.py 2011-10-30 22:09:37 UTC (rev 312) @@ -18,6 +18,8 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +import xmlrpclib + from igeclient import IClient, IClientDB from ige.ospace import Rules from ige.ospace.Const import * @@ -34,12 +36,14 @@ serverVersion = None ignoreMsgs = {} nonexistingObj = {} -optins = None +options = None +galaxer = None def initialize(aServer, aCallbackObj, anOptions): - global callbackObj, server, options + global callbackObj, server, options, galaxer callbackObj = aCallbackObj server = aServer + galaxer = xmlrpclib.ServerProxy(gdata.config.galaxer.server) options = anOptions initCmdProxy(options.heartbeat) @@ -111,8 +115,21 @@ log.message('OSClient', 'Saving database') db.save() -## Message handler +## Part for communication with Galaxer +def getGalaxerData(): + global cmdProxy, galaxer + token = cmdProxy.getToken() + galaxerData = galaxer.getDataForPlayer(token) + return galaxerData +def setPlayerPreference(galType): + global cmdProxy, galaxer + token = cmdProxy.getToken() + galaxerData = galaxer.setPlayerPreference(token, galType) + return galaxerData + + ## Message handler + def msgHandler(mid, data): if ignoreMsgs.has_key(mid): log.debug('OSClient', 'ignoring message', mid, data) Added: branches/ospace_0.5/client-pygame/lib/osci/dialog/GalaxerDlg.py =================================================================== --- branches/ospace_0.5/client-pygame/lib/osci/dialog/GalaxerDlg.py (rev 0) +++ branches/ospace_0.5/client-pygame/lib/osci/dialog/GalaxerDlg.py 2011-10-30 22:09:37 UTC (rev 312) @@ -0,0 +1,118 @@ +# +# Copyright 2001 - 2011 Ludek Smid [http://www.ospace.net/] +# +# This file is part of Outer Space. +# +# Outer Space is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# Outer Space is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Outer Space; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +import time + +import pygameui as ui +from osci import client, gdata, res +from ige.ospace.Const import * +import ige +from MainGameDlg import MainGameDlg + +class GalaxerDlg: + """ There you subscribe to the new galaxy.""" + + def __init__(self, app): + self.app = app + self.createUI() + self.galaxerInfo = client.getGalaxerData() + + def display(self, caller = None): + self.caller = caller + if self.show(): + self.win.show() + + def hide(self): + self.win.hide() + + def show(self): + items = [] + for galaxyType in self.galaxerInfo: + info, tPos, tCur, rawTime, isSelected = self.galaxerInfo[galaxyType] + if rawTime: + tTime = time.strftime(_("%m-%d-%y %H:%M"), time.localtime(rawTime)) + else: + tTime = _('N/A') + if isSelected: + tChoice = '*' + else: + tChoice = '' + item = ui.Item(galaxyType, tPos = tPos, tCur = tCur, tTime = tTime,tChoice = tChoice) + items.append(item) + self.win.vGalaxer.items = items + self.win.vGalaxer.itemsChanged() + return True + + def onSelect(self, widget, action, data): + self.win.vInfo.text = [self.galaxerInfo[data.text][0]] + self.win.vInfo.offsetRow = 0 + self.win.vInfo.vertScrollbar.slider.position = 0 + return + + def onToggle(self, widget, action, data): + selection = self.win.vGalaxer.selection + try: + selectedType = selection[0].text + except IndexError: + selectedType = None + if selectedType: + result = client.setPlayerPreference(selectedType) + if not type(result) == type(True) and not result == True: + self.galaxerInfo = result + self.show() + else: + self.win.setStatus(_('Command has been executed.')) + self.hide() + if not gdata.mainGameDlg: + gdata.mainGameDlg = MainGameDlg(self.app) + gdata.mainGameDlg.display() + client.updateDatabase(clearDB = 1) + + def onCancel(self, widget, action, data): + self.win.hide() + if self.caller: + self.caller.display() + else: + self.app.exit() + + def createUI(self): + w, h = gdata.scrnSize + self.win = ui.Window(self.app, + modal = 1, + movable = 0, + title = _('Select, which galaxy types do you want to play'), + rect = ui.Rect((w - 424) / 2, (h - 264) / 2, 424, 264), + layoutManager = ui.SimpleGridLM(), + tabChange = True + ) + ui.Listbox(self.win, layout = (0, 0, 21, 6), id = 'vGalaxer', + columns = ( (_('Galaxy type'), 'text', 5, ui.ALIGN_W), + (_('Capacity'), 'tPos', 3, ui.ALIGN_NONE), + (_('Queue'), 'tCur', 3, ui.ALIGN_NONE), + (_('Last start'), 'tTime', 8, ui.ALIGN_E), + (_(''), 'tChoice', 1, ui.ALIGN_NONE)), + columnLabels = 1, action = 'onSelect') + self.win.subscribeAction('*', self) + scrollBar = ui.Scrollbar(self.win, layout = (20, 6, 1, 4)) + textBox = ui.Text(self.win, layout = (0, 6, 20, 4), id = "vInfo", editable = 0) + textBox.attachVScrollbar(scrollBar) + ui.TitleButton(self.win, layout = (0, 10, 21, 1), text = _('Toggle booking'), action = 'onToggle') + ui.Title(self.win, layout = (0, 11, 17, 1), id = 'vStatusBar', align = ui.ALIGN_W) + ui.TitleButton(self.win, layout = (17, 11, 4, 1), text = _('Exit'), action = 'onCancel') + self.win.statusBar = self.win.vStatusBar Modified: branches/ospace_0.5/client-pygame/lib/osci/dialog/NewAccountDlg.py =================================================================== --- branches/ospace_0.5/client-pygame/lib/osci/dialog/NewAccountDlg.py 2011-10-23 16:23:20 UTC (rev 311) +++ branches/ospace_0.5/client-pygame/lib/osci/dialog/NewAccountDlg.py 2011-10-30 22:09:37 UTC (rev 312) @@ -23,6 +23,7 @@ from ige.ospace.Const import * from MainGameDlg import MainGameDlg from ConfirmDlg import ConfirmDlg +from GalaxerDlg import GalaxerDlg import ige class NewAccountDlg: @@ -44,13 +45,6 @@ def show(self): positions = client.cmdProxy.getStartingPositions() - if not positions: - # there are no positions -- pop up a dialog - self.confirmDlg.display( - _("We are sorry, but there are no starting positions available at this moment. Please, try again later."), - _("Refresh"), _("Exit"), self.display, self.app.exit - ) - return False items = [] for objID, name, posType in positions: item = ui.Item(name, tObjID = objID, tPosType = posType) @@ -107,6 +101,15 @@ gdata.mainGameDlg.display() client.updateDatabase(clearDB = 1) + def onGalaxer(self, widget, action, data): + try: + client.galaxer.test() + self.win.hide() + self.win.setStatus(_('Command has been executed.')) + GalaxerDlg(gdata.app).display(self) + except Exception: + self.win.setStatus(_('Galaxer not present.')) + def onCancel(self, widget, action, data): self.win.hide() if self.caller: @@ -130,6 +133,7 @@ self.win.subscribeAction('*', self) ui.Label(self.win, layout = (0, 10, 5, 1), text = _("VIP Password:")) ui.Entry(self.win, layout = (5, 10, 5, 1), id = 'vPassword', align = ui.ALIGN_W, showChar = '*', orderNo = 1 ) + ui.TitleButton(self.win, layout = (13, 10, 8, 1), text = _('Book position'), action = 'onGalaxer') ui.Title(self.win, layout = (0, 11, 13, 1), id = 'vStatusBar', align = ui.ALIGN_W) ui.TitleButton(self.win, layout = (13, 11, 4, 1), text = _('Exit'), action = 'onCancel') ui.TitleButton(self.win, layout = (17, 11, 4, 1), text = _('Select'), action = 'onSelect') Modified: branches/ospace_0.5/client-pygame/lib/osci/main.py =================================================================== --- branches/ospace_0.5/client-pygame/lib/osci/main.py 2011-10-23 16:23:20 UTC (rev 311) +++ branches/ospace_0.5/client-pygame/lib/osci/main.py 2011-10-30 22:09:37 UTC (rev 312) @@ -74,7 +74,11 @@ default = 180, help = "Heartbeat for server connection" ) - +parser.add_option("", "--galaxer", dest = "galaxer", + metavar = "PROTOCOL://HOSTNAME:PORT", + default = "http://www.ospace.net:9081", + help = "Outer Space galaxy booking system location" +) options, args = parser.parse_args() if args: @@ -165,6 +169,7 @@ # default configuration gdata.config.game.server = options.server +gdata.config.galaxer.server = options.galaxer if gdata.config.client.language == None: gdata.config.client.language = 'en' Modified: branches/ospace_0.5/server/lib/ige/ClientMngr.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ClientMngr.py 2011-10-23 16:23:20 UTC (rev 311) +++ branches/ospace_0.5/server/lib/ige/ClientMngr.py 2011-10-30 22:09:37 UTC (rev 312) @@ -62,6 +62,9 @@ password = hashlib.sha1(str(random.randrange(0, 1e10))).hexdigest() open(os.path.join(self.configDir, "token"), "w").write(password) self.accounts[ADMIN_LOGIN].passwd = password + # tokens to provide player identification + # to external parts of server (Galaxer) + self.tokens = {} def shutdown(self): self.accounts.shutdown() @@ -175,8 +178,12 @@ self.sessions[sid].setAttrs(account.login, account.nick, account.email) account.lastLogin = time.time() account.addHostID(hostID) + self.tokens[sid] = hashlib.md5(str(random.random())).hexdigest() return 1, None + def getToken(self, sid): + return self.tokens[sid], None + def getSession(self, sid): session = self.sessions.get(sid, None) if not session: @@ -191,6 +198,16 @@ return session return None + def getSessionByToken(self, sid, token): + # check admin + session = self.getSession(sid) + if session.login != "admin": + raise SecurityException('You cannot issue this command.') + for sid in self.tokens: + if self.tokens[sid] == token: + return self.getSession(sid), None + return 0, None + def logout(self, sid): session = self.sessions.get(sid, None) if session: @@ -199,6 +216,7 @@ except AttributeError: pass del self.sessions[sid] + del self.tokens[sid] return 1, None else: raise SecurityException('No such session id.') Modified: branches/ospace_0.5/server/lib/ige/LimitedClientMngr.py =================================================================== --- branches/ospace_0.5/server/lib/ige/LimitedClientMngr.py 2011-10-23 16:23:20 UTC (rev 311) +++ branches/ospace_0.5/server/lib/ige/LimitedClientMngr.py 2011-10-30 22:09:37 UTC (rev 312) @@ -128,6 +128,9 @@ account.addHostID(hostID) return 1, None + def getToken(self, sid): + return self.tokens[sid], None + def getSession(self, sid): session = self.sessions.get(sid, None) if not session: Modified: branches/ospace_0.5/server/lib/ige/RPCServer.py =================================================================== --- branches/ospace_0.5/server/lib/ige/RPCServer.py 2011-10-23 16:23:20 UTC (rev 311) +++ branches/ospace_0.5/server/lib/ige/RPCServer.py 2011-10-30 22:09:37 UTC (rev 312) @@ -157,6 +157,8 @@ callMap['cleanupSessions'] = clientMngr.cleanupSessions callMap['exportAccounts'] = clientMngr.exportAccounts callMap['getVersion'] = versionHandler + callMap['getToken'] = clientMngr.getToken + callMap['getSessionByToken'] = clientMngr.getSessionByToken def register(game): global callMap Modified: branches/ospace_0.5/server/lib/ige/ospace/GalaxyGenerator.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/GalaxyGenerator.py 2011-10-23 16:23:20 UTC (rev 311) +++ branches/ospace_0.5/server/lib/ige/ospace/GalaxyGenerator.py 2011-10-30 22:09:37 UTC (rev 312) @@ -42,7 +42,7 @@ self.galaxyPlayerGroup = 1 self.galaxyGroupDist = 1 self.galaxyMinR = 5 - self.galaxyDensity = {5: 2, 10: 2, 20: 3, 30: 4, 40: 5, 50: 6} + self.galaxyDensity = {5: 3, 10: 3.5, 20: 4} self.galaxyResources = { # format resourceID : (minDist, maxDist, number of resources) 1 : (12, 15, 2), # TL 1 + 2 @@ -155,7 +155,22 @@ self.activeGalaxy = self.galaxies[galaxyID] self.activeGalaxy() - + +class GalaxyGenerator: + def __init__(self): + self.galaxyTypes = {'Circle9P':(9, 'Smaller galaxy for 9 players, without pirate or EDEN. Recommended for new players or those who seek more casual gameplay.'), + 'Circle42P':(42, 'Original size galaxy for 42 players, place of epic battles, recommended only to the experienced players. May be quite time consuming.')} + + def generateGalaxy(self, galaxyType, fileHandle): + if not galaxyType in self.galaxyTypes.keys(): + return False + else: + GenerateGalaxy(galaxyType, fileHandle) + return True + + def getGalaxyTypes(self): + return self.galaxyTypes + # galaxy specification for GalaxyGenerator() [not used anymore] sectorSize = [10, 10] sectorsOffset = [0, 0] Modified: branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py 2011-10-23 16:23:20 UTC (rev 311) +++ branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py 2011-10-30 22:09:37 UTC (rev 312) @@ -23,6 +23,7 @@ import ige from ige import log +from ige.ClientMngr import Session from ige.GameMngr import GameMngr as IGEGameMngr from ige.Index import Index from ige.Transaction import Transaction @@ -257,9 +258,7 @@ self.generateGameInfo() return player.oid, None - def createNewPlayer(self, sid, galaxyID): - log.debug('Creating new player in session', sid) - session = self.clientMngr.getSession(sid) + def _createNewPlayer(self, session, galaxyID): log.debug('Creating new player with CID', session.cid) universe = self.db[OID_UNIVERSE] galaxy = self.db[galaxyID] @@ -355,8 +354,19 @@ self.cmdPool[T_GALAXY].enableTime(tran, galaxy) # save game info self.generateGameInfo() - return playerID, None + return playerID, None + def createNewPlayer(self, sid, galaxyID): + log.debug('Creating new player in session', sid) + session = self.clientMngr.getSession(sid) + self._createNewPlayer(session, galaxyID) + + def createNewSubscribedPlayer(self, (login, nick, email), galaxyID): + log.debug('Creating new subscribed player using fake session') + session = Session(None) + session.setAttrs(login, nick, email) + self._createNewPlayer(session, galaxyID) + def removePlayer(self, playerID): log.debug('removePlayer', playerID) player = self.db[playerID] Modified: branches/ospace_0.5/server/lib/ige/ospace/IGalaxy.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/IGalaxy.py 2011-10-23 16:23:20 UTC (rev 311) +++ branches/ospace_0.5/server/lib/ige/ospace/IGalaxy.py 2011-10-30 22:09:37 UTC (rev 312) @@ -53,6 +53,7 @@ obj.timeEnabled = 0 # TODO change to 0 obj.timeStopped = 0 obj.creationTime = 0.0 + obj.bookedCreation = False obj.imperator = OID_NONE obj.description = "" # electromagnetic radiation @@ -83,6 +84,9 @@ # check compOf if not tran.db.has_key(obj.compOf) or tran.db[obj.compOf].type != T_UNIVERSE: log.debug("CONSISTENCY invalid compOf for galaxy", obj.oid, obj.compOf) + # TODO remove after 0.5.69 + if not hasattr(obj, 'bookedCreation'): + obj.bookedCreation = False update.public = 0 @@ -91,6 +95,12 @@ getReferences.public = 0 + def bookedInit(self, tran, obj): + obj.bookedCreation = True + + bookedInit.public = 1 + bookedInit.accLevel = AL_ADMIN + def processINITPhase(self, tran, obj, data): # compute emr level turn = tran.db[OID_UNIVERSE].turn @@ -308,7 +318,7 @@ # log.debug("Half galaxy populated", len(obj.startingPos), obj.numOfStartPos) # canRun = 1 # at least two days must pass from creation - if not obj.startingPos: + if not obj.startingPos and not obj.bookedCreation: log.debug("All positions taken, starting galaxy") canRun = 1 if obj.creationTime < time.time() - 2 * 24 * 3600: @@ -452,6 +462,12 @@ delete.public = 1 delete.accLevel = AL_ADMIN + def getGalaxerInfo(self, tran, obj): + return obj.name, obj.x, obj.y, obj.radius + + getGalaxerInfo.public = 1 + getGalaxerInfo.accLevel = AL_ADMIN + def getPublicInfo(self, tran, obj): result = IDataHolder() result.oid = obj.oid Modified: branches/ospace_0.5/server/lib/ige/ospace/IPlanet.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/IPlanet.py 2011-10-23 16:23:20 UTC (rev 311) +++ branches/ospace_0.5/server/lib/ige/ospace/IPlanet.py 2011-10-30 22:09:37 UTC (rev 312) @@ -901,11 +901,6 @@ if not deletedKey: loopAgain = False - # TODO: remove in 0.5.34 - for struct in obj.slots: - if len(struct) < 4: - # add oper status - struct.append(100) # change owner to OID_NONE when owner is invalid if obj.owner != OID_NONE: player = tran.db.get(obj.owner, None) @@ -916,12 +911,6 @@ # kill all population obj.storPop = 0 return - # TODO: remove in 0.5.65 - obj.storBio = int(obj.storBio) - obj.storEn = int(obj.storEn) - # TODO: remove in 0.5.69 - if not hasattr(obj, "globalQueue"): - obj.globalQueue = 0 # check compOf if not tran.db.has_key(obj.compOf) or tran.db[obj.compOf].type != T_SYSTEM: log.debug("CONSISTENCY invalid compOf for planet", obj.oid) Modified: branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py =================================================================== --- branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py 2011-10-23 16:23:20 UTC (rev 311) +++ branches/ospace_0.5/server/lib/ige/ospace/IUniverse.py 2011-10-30 22:09:37 UTC (rev 312) @@ -28,6 +28,7 @@ import ige.version from ige import log from GalaxyGenerator import GenerateGalaxy +import GalaxyGenerator from ige import GameException class IUniverse(IObject): @@ -49,6 +50,7 @@ obj.owner = OID_ADMIN obj.galaxies = [] obj.players = [] + obj.waitingPlayers = [] # auto loading of galaxies obj.galX = 0.0 obj.galY = 0.0 @@ -409,6 +411,13 @@ getReferences.public = 0 + def getPossibleGalaxyTypes(self, tran, obj): + galGen = GalaxyGenerator.GalaxyGenerator() + return galGen.getGalaxyTypes() + + getPossibleGalaxyTypes.public = 1 + getPossibleGalaxyTypes.accLevel = AL_ADMIN + def getPublicInfo(self, tran, obj): result = IDataHolder() result.oid = obj.oid @@ -461,36 +470,15 @@ } self.cmd(obj).sendMsg(tran, obj, message) - fh, galaxyFileName = tempfile.mkstemp(text = True) - log.debug("Generating new galaxy to temporary file", galaxyFileName) - strGalaxyID = tran.gameMngr.config.server.newgalaxytype - GenerateGalaxy(strGalaxyID, os.fdopen(fh, "w+b")) oldX = galaxy.x oldY = galaxy.y oldName = galaxy.name + # not created by booker - will restart it + restart = not galaxy.bookedCreation log.debug("Deleting galaxy", galaxyID) self.cmd(galaxy).delete(tran, galaxy) - log.debug("Creating new galaxy") - newGalaxyID = self.createGalaxy(tran, obj) - log.debug("Created new galaxy", newGalaxyID) - newGalaxy = tran.db[newGalaxyID] - log.debug("Loading new ", newGalaxyID) - self.cmd(newGalaxy).loadFromXML(tran, newGalaxy, galaxyFileName, strGalaxyID, oldX, oldY, oldName) - log.debug("Setup Enviroment", newGalaxyID) - self.cmd(newGalaxy).setupEnvironment(tran, newGalaxy) - log.debug("Sending Announcement Message", newGalaxyID) - #self.cmd(newGalaxy).announceGalaxy(tran,newGalaxy) - log.debug("Removing temp file", galaxyFileName) - os.remove(galaxyFileName) - # TODO: find you what's this code about - #message = { - # "sender": 'Galaxy %s' % oldName, - # "senderID": obj.oid, - # "forum": "NEWS", - # "data": (obj.oid, MSG_GNC_GALAXY_GENERATOR, obj.oid, tran.db[OID_UNIVERSE].turn, (oldName, newGalaxy.description)), - # "topic": "EVENT", - #} - log.debug("Galaxy Restarting END") + if restart: + self.cmd(obj).createNewGalaxy(self, tran, obj, oldX, oldY, oldName) restartGalaxy.public = 1 restartGalaxy.accLevel = AL_NONE @@ -508,41 +496,47 @@ "topic": "EVENT", } self.cmd(obj).sendMsg(tran, obj, message) - - fh, galaxyFileName = tempfile.mkstemp(text = True) - log.debug("Generating new galaxy to temporary file", galaxyFileName) - strGalaxyID = tran.gameMngr.config.server.newgalaxytype - GenerateGalaxy(strGalaxyID, os.fdopen(fh, "w+b")) oldX = galaxy.x oldY = galaxy.y oldName = galaxy.name + # not created by booker - will restart it + restart = not galaxy.bookedCreation log.debug("Deleting galaxy", galaxyID) self.cmd(galaxy).delete(tran, galaxy) + if restart: + self.cmd(obj).createNewGalaxy(self, tran, obj, oldX, oldY, oldName) + + restartGalaxy2.public = 1 + restartGalaxy2.accLevel = AL_ADMIN + + def createNewSubscribedGalaxy(self, tran, obj, x, y, galaxyName, galaxyType, listOfPlayers): + log.message("Adding new galaxy '%s' to (%d, %d)" % (galaxyName, x, y)) + fileHandle, galaxyFileName = tempfile.mkstemp(text = True) + log.debug("Generating new galaxy to temporary file", galaxyFileName) + galGen = GalaxyGenerator.GalaxyGenerator() + galGen.generateGalaxy(galaxyType, os.fdopen(fileHandle, "w+b")) log.debug("Creating new galaxy") newGalaxyID = self.createGalaxy(tran, obj) log.debug("Created new galaxy", newGalaxyID) newGalaxy = tran.db[newGalaxyID] log.debug("Loading new ", newGalaxyID) - self.cmd(newGalaxy).loadFromXML(tran, newGalaxy, galaxyFileName, strGalaxyID, oldX, oldY, oldName) + self.cmd(newGalaxy).loadFromXML(tran, newGalaxy, galaxyFileName, galaxyType, x, y, galaxyName) + log.debug("Running scripts specific to booked galaxies", newGalaxyID) + self.cmd(newGalaxy).bookedInit(tran, newGalaxy) log.debug("Setup Enviroment", newGalaxyID) self.cmd(newGalaxy).setupEnvironment(tran, newGalaxy) log.debug("Sending Announcement Message", newGalaxyID) #self.cmd(newGalaxy).announceGalaxy(tran,newGalaxy) log.debug("Removing temp file", galaxyFileName) os.remove(galaxyFileName) - # TODO: find you what's this code about - #message = { - # "sender": 'Galaxy'+galaxyName, - # "senderID": obj.oid, - # "forum": "NEWS", - # "data": (obj.oid, MSG_GNC_GALAXY_GENERATOR, obj.oid, tran.db[OID_UNIVERSE].turn, (galaxyName, newGalaxy.description)), - # "topic": "EVENT", - #} - log.debug("Galaxy Restarting END") + for playerInfo in listOfPlayers: + tran.gameMngr.createNewSubscribedPlayer(playerInfo, newGalaxyID) + log.debug("Galaxy creation END") - restartGalaxy2.public = 1 - restartGalaxy2.accLevel = AL_ADMIN - + createNewSubscribedGalaxy.public = 1 + createNewSubscribedGalaxy.accLevel = AL_ADMIN + + def createNewGalaxy(self, tran, obj, x, y, galaxyName): log.message("Adding new galaxy '%s' to (%d, %d)" % (galaxyName, x, y)) fh, galaxyFileName = tempfile.mkstemp(text = True) @@ -569,7 +563,7 @@ # "data": (obj.oid, MSG_GNC_GALAXY_GENERATOR, obj.oid, tran.db[OID_UNIVERSE].turn, (galaxyName, newGalaxy.description)), # "topic": "EVENT", #} - log.debug("Galaxy Restarting END") + log.debug("Galaxy creation END") createNewGalaxy.public = 1 createNewGalaxy.accLevel = AL_ADMIN Modified: branches/ospace_0.5/server/lib/igeclient/IClient.py =================================================================== --- branches/ospace_0.5/server/lib/igeclient/IClient.py 2011-10-23 16:23:20 UTC (rev 311) +++ branches/ospace_0.5/server/lib/igeclient/IClient.py 2011-10-30 22:09:37 UTC (rev 312) @@ -92,6 +92,12 @@ def getVersion(self): return apply(IProxy('getVersion', None, self), ()) + def getToken(self): + return apply(IProxy('getToken', None, self), ()) + + def getSessionByToken(self, token): + return apply(IProxy('getSessionByToken', None, self), (token,)) + def cleanupSessions(self): return apply(IProxy('cleanupSessions', None, self), ()) Added: branches/ospace_0.5/server/run_galaxer.py =================================================================== --- branches/ospace_0.5/server/run_galaxer.py (rev 0) +++ branches/ospace_0.5/server/run_galaxer.py 2011-10-30 22:09:37 UTC (rev 312) @@ -0,0 +1,281 @@ +# +# Copyright 2001 - 2011 Ludek Smid [http://www.ospace.net/] +# +# This file is part of Outer Space. +# +# Outer Space is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# Outer Space is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Outer Space; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +import atexit +import optparse +import os +import sys +import time +import xmlrpclib +import sqlite3 +from SimpleXMLRPCServer import SimpleXMLRPCServer + +sys.path.insert(0, 'lib') + +from igeclient.IClient import IClient +from ige.ClientMngr import Session +from ige.Const import * +from ige.ospace import Const + +def msgHandler(id, data): + if id >= 0: + print 'Message', id, data + +def _adminLogin(): + s = IClient(options.server, None, msgHandler, None, 'IClient/osc') + login = 'admin' + password = open(os.path.join(options.configDir, "token"), "r").read() + s.connect(login) + s.login('Alpha', login, password) + return s + +def _adminLogout(s): + s.logout() + +def _getActualGalaxies(): + un = s.getInfo(OID_UNIVERSE) + galaxies = {} + response = '' + for galaxyID in un.galaxies: + galaxerInfo = s.getGalaxerInfo(galaxyID) + galaxies[galaxyID] = galaxerInfo + return galaxies + +def _getActivePlayers(): + un = s.getInfo(OID_UNIVERSE) + players = [] + for playerID in un.players: + player = s.getInfo(playerID) + if not player.type in Const.AI_PLAYER_TYPES: + players.append(player.name) + return players + +def setPlayerPreference(token, galType): + global db + session = s.getSessionByToken(token) + if session: + if session.nick in _getActivePlayers(): + # player is already in the game + return True + query = db.execute('SELECT nick FROM players\ + WHERE nick=? AND galType=?', + (session.nick, galType)).fetchone() + if query: + db.execute('DELETE FROM players\ + WHERE nick=? AND galType=?', + (session.nick, galType)) + else: + db.execute('INSERT INTO players (nick, login, email, time, galType)\ + VALUES (?, ?, ?, ?, ?)', + (session.nick, session.login, session.email, time.time(), galType)) + + result = testBooking() + if result: + return result + db.commit() + return getDataForPlayer(token) + +def getDataForPlayer(token): + global db + session = s.getSessionByToken(token) + types = s.getPossibleGalaxyTypes(OID_UNIVERSE) + finalInfo = {} + if session: + playerNick = session.nick + for galType in types: + playerCapacity, infoText = types[galType] + query = db.execute('SELECT COUNT(*), galType\ + FROM players GROUP BY galType\ + HAVING galType=?', (galType,)).fetchone() + if query: + actualBooked = query[0] + else: + actualBooked = 0 + hasBooked = bool(db.execute('SELECT nick FROM players\ + WHERE nick=? AND galType=?', + (playerNick, galType)).fetchone()) + # find out, when was the galaxy created for the last time + query = db.execute('SELECT lastCreation FROM galaxies\ + WHERE galType=?', + (galType,)).fetchone() + + if query: + lastTime = query[0] + else: + lastTime = 0 + finalInfo[galType] = (infoText, playerCapacity, actualBooked, lastTime, hasBooked) + return finalInfo + +def testBooking(): + global db + modifier = 1 + query = db.execute('SELECT galType, COUNT(*) FROM players\ + GROUP BY galType', ()).fetchall() + types = s.getPossibleGalaxyTypes(OID_UNIVERSE) + for galType, count in query: + galCap, galInfo = types[galType] + if galCap * modifier <= count: + return createNewGalaxy(galType, galCap) + +def createNewGalaxy(galType, galCap): + actualGalaxies = _getActualGalaxies() + galPositions = set([]) + galNames = set([]) + maxCoordinate = 0 + names = ['Argo', 'Beidos', 'Ceelia', 'Daela', 'Everen', 'Ferun', 'Garis', 'Hiron', 'Inera', 'Jinx', 'Kelenor', 'Larion', 'Merlis'] + for galaxyID in actualGalaxies: + galName, galX, galY, galRadius = actualGalaxies[galaxyID] + galX = int(galX) + galY = int(galY) + galRadius = int(galRadius) + galNames.add(galName) + galPositions.add((galX, galY)) + maxCoordinate = max(maxCoordinate, galX, galY) + if galRadius > 50 or galX % 100 or galY % 100: + raise NotImplementedError + # get list of booked players, and delete + # their records from the booking system + query = db.execute('SELECT login, nick, email FROM players\ + WHERE galType=? ORDER BY time ASC', + (galType,)).fetchall() + listOfPlayers = [] + for playerInfo in query[:galCap]: + nick = playerInfo[1] + listOfPlayers.append(playerInfo) + db.execute('DELETE FROM players\ + WHERE nick=?', + (nick,)) + # now we need to find the place for it + squareSide = maxCoordinate / 200 + 1 + if squareSide**2 == len(actualGalaxies): + squareSide += 1 + hasFound = False + for y in xrange(squareSide): + posY = y * 200 + 100 + for x in xrange(squareSide): + posX = x * 200 + 100 + if (posX, posY) in galPositions: + continue + hasFound = True + if hasFound: + break + if hasFound: + break + # searching for free name for the galaxy + nameFound = False + for name in names: + if name in galNames: + continue + nameFound = True + break + if not nameFound: + # cannot be created, no free name + # TODO: report it + return False + # create the galaxy + s.createNewSubscribedGalaxy(OID_UNIVERSE, posX, posY, name, galType, listOfPlayers) + # record the creation time + query = db.execute('SELECT lastCreation FROM galaxies\ + WHERE galType=?', + (galType,)).fetchone() + if query: + db.execute('UPDATE galaxies SET lastCreation=?\ + WHERE galType=?', + (time.time(), galType)) + else: + db.execute('INSERT INTO galaxies (galType, lastCreation)\ + VALUES (?, ?)', + (galType, time.time())) + db.commit() + return True + +def test(): + return True + +def initDatabase(): + db = sqlite3.connect(os.path.join(options.configDir, 'galaxer.db')) + rows = db.execute('SELECT name FROM sqlite_master WHERE type = "table"') + tables = set([]) + for row in rows.fetchall(): + tables.add(row[0]) + if not 'players' in tables: + db.execute('CREATE TABLE players (login,\ + nick,\ + email,\ + time,\ + galType,\ + PRIMARY KEY (nick,\ + galType))\ + ') + if not 'galaxies' in tables: + db.execute('CREATE TABLE galaxies (galType,\ + lastCreation,\ + PRIMARY KEY (galType))\ + ') + return db + + +parser = optparse.OptionParser() +parser.add_option("", "--configdir", dest = "configDir", + metavar = "DIRECTORY", + default = "var", + help = "Override default configuration directory", +) +parser.add_option("", "--OSserver", dest = "server", + metavar = "HOSTNAME:PORT", + default = "localhost:9080", + help = "Outer Space server location" +) +parser.add_option("", "--address", dest = "address", + metavar = "HOSTNAME:PORT", + default = "localhost:9081", + help = "Outer Space galaxer location" +) + +options, args = parser.parse_args() + +if args: + parser.error("No additional arguments are supported") + +# record my pid +pidFd = os.open(os.path.join(options.configDir,"galaxer.pid"), os.O_CREAT | os.O_EXCL | os.O_WRONLY) +os.write(pidFd, str(os.getpid())) + +# define and register exit function +def cleanup(): + # delete my pid + os.close(pidFd) + os.remove(os.path.join(options.configDir,"galaxer.pid")) + +atexit.register(cleanup) + +db = initDatabase() +s = _adminLogin() +address, strPort = options.address.split(':') +port = int(strPort) +server = SimpleXMLRPCServer((address, port)) +server.register_function(setPlayerPreference, 'setPlayerPreference') +server.register_function(getDataForPlayer, 'getDataForPlayer') +server.register_function(test, 'test') +try: + server.serve_forever() +except: + db.commit() + _adminLogout(s) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |