Advertisement
Guest User

Untitled

a guest
Nov 14th, 2012
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.23 KB | None | 0 0
  1. function cStation::InitNewStation(stationID)
  2. // Create a station object depending on station type. Add the station to base and return the station object or null on error.
  3. {
  4.     if (!AIStation.IsValidStation(stationID))
  5.         {
  6.         DError("Station #"+stationID+" doesn't exist");
  7.         return null;
  8.         }
  9.     local _StationType = cStation.FindStationType(stationID);
  10.     if (_StationType == -1) { DError("Couldn't determine station type use by station #"+stationID); return null; }
  11.     local _Location = AIStation.GetLocation(stationID);
  12.     local _station = null;
  13. print(_station);
  14.     switch (_StationType)
  15.         {
  16.         case    AIStation.STATION_TRAIN:
  17.             _station = cStationRail();
  18.             _station.s_SubType = AIRail.GetRailType(_Location); // set rail type the station use
  19.             _station.s_MaxSize = INSTANCE.main.carrier.rail_max;
  20.             for (local zz=0; zz < 23; zz++) _station.s_TrainSpecs.AddItem(zz,-1); // create special cases for train usage
  21.             for (local zz=7; zz < 11; zz++) _station.s_TrainSpecs.SetValue(zz,0);
  22.             _station.s_TrainSpecs.SetValue(0,1+2); // enable IN && OUT for the new station
  23.             _station.s_Tiles = cTileTools.FindStationTiles(_Location);
  24.             _station.s_Radius = AIStation.GetCoverageRadius(_StationType);
  25.             _station.GetRailStationMiscInfo();
  26.         break;
  27.         case    AIStation.STATION_DOCK:     // TODO: do boat
  28.             _station = cStationWater();
  29.         break;
  30.         case    AIStation.STATION_BUS_STOP:
  31. print("bus");
  32.         case    AIStation.STATION_TRUCK_STOP:
  33. print("truck");
  34. print("station ? "+_station);
  35.             _station = cStationRoad();
  36. //_station = "hell";
  37. print("station ? "+_station);
  38.             _station.s_MaxSize = INSTANCE.main.carrier.road_max;
  39.             _station.s_Tiles = cTileTools.FindStationTiles(_Location);
  40.             _station.s_Size = _station.s_Tiles.Count();
  41.             _station.s_SubType = AIRoad.ROADTYPE_ROAD;
  42.             if (AIRoad.HasRoadType(_Location, AIRoad.ROADTYPE_TRAM))    _station.s_SubType = AIRoad.ROADTYPE_TRAM;
  43. print("ailist="+(_station.s_Tiles instanceof AIList));
  44. print("s_tile="+_station.s_Tiles+" empty="+_station.s_Tiles.IsEmpty());
  45. //          foreach (loc, _dummy in _station.s_Tiles)   { _station.s_Tiles.SetValue(loc, AIRoad.GetRoadStationFrontTile(loc)); } // keeping it comment
  46.             local grrr = AIList();
  47.             grrr.AddList(_station.s_Tiles);
  48.             foreach (_stupidloc, _stupiddummy in grrr)  { print("trigger bug"); }  // commenting out this line it stop at bugme(), but if i kept it uncomment, it stop at print("after station... position
  49.             _station.s_Radius = AIStation.GetCoverageRadius(_StationType);
  50. print("break station ? "+_station);
  51.         break;
  52.         case    AIStation.STATION_AIRPORT:
  53.             _station = cStationAir();
  54.             _station.s_MaxSize = 1000; // airport size is limited by airport avaiability
  55.             _station.s_Tiles = cTileTools.FindStationTiles(_Location);
  56.             _station.s_Size = _station.s_Tiles.Count();
  57.             _station.s_SubType = AIAirport.GetAirportType(_Location);
  58.             _station.s_Radius = AIAirport.GetAirportCoverageRadius(_station.s_SubType);
  59.             _station.s_Depot = AIAirport.GetHangarOfAirport(_Location);
  60.         break;
  61.         }
  62.     // now common properties
  63. print("after station ? "+_station); // <- bug it stop here with _station doesn't exist error
  64. print("tiles count "+_station.s_Tiles.Count());
  65. bugme();
  66.  
  67.  
  68. uncomment version result :
  69. dbg: [script] [1] [P] bus
  70. dbg: [script] [1] [P] truck
  71. dbg: [script] [1] [P] station ? (null : 0x(nil))
  72. dbg: [script] [1] [P] station ? (instance : 0x0xa961168)
  73. dbg: [script] [1] [P] ailist=true
  74. dbg: [script] [1] [P] s_tile=(instance : 0x0xc60c110) empty=false
  75. dbg: [script] [1] [P] trigger bug
  76. dbg: [script] [1] [P] break station ? (instance : 0x0xa961168)
  77. dbg: [script] [1] [S] Your script made an error: the index '_station' does not exist
  78. dbg: [script] [1] [S]
  79. dbg: [script] [1] [S] *FUNCTION [InitNewStation()] TheDictator/class/cstation.nut line [220]
  80.  
  81. and line comment result :
  82. dbg: [script] [1] [P] bus
  83. dbg: [script] [1] [P] truck
  84. dbg: [script] [1] [P] station ? (null : 0x(nil))
  85. dbg: [script] [1] [P] station ? (instance : 0x0xcedee70)
  86. dbg: [script] [1] [P] ailist=true
  87. dbg: [script] [1] [P] s_tile=(instance : 0x0xcedee20) empty=false
  88. dbg: [script] [1] [P] break station ? (instance : 0x0xcedee70)
  89. dbg: [script] [1] [P] after station ? (instance : 0x0xcedee70)
  90. dbg: [script] [1] [P] tiles count 1
  91. dbg: [script] [1] [S] Your script made an error: the index 'bugme' does not exist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement