equal
deleted
inserted
replaced
399 |
399 |
400 if (_game_mode == GM_EDITOR) |
400 if (_game_mode == GM_EDITOR) |
401 return; |
401 return; |
402 |
402 |
403 i = _cur_town_ctr; |
403 i = _cur_town_ctr; |
404 t = DEREF_TOWN(i); |
404 t = GetTown(i); |
405 if (++i == lengthof(_towns)) i = 0; |
405 if (++i == _towns_size) i = 0; |
406 _cur_town_ctr = i; |
406 _cur_town_ctr = i; |
407 |
407 |
408 if (t->xy != 0) |
408 if (t->xy != 0) |
409 TownTickHandler(t); |
409 TownTickHandler(t); |
410 |
410 |
1352 } |
1352 } |
1353 |
1353 |
1354 int32 CmdRenameTown(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
1354 int32 CmdRenameTown(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
1355 { |
1355 { |
1356 StringID str; |
1356 StringID str; |
1357 Town *t = DEREF_TOWN(p1); |
1357 Town *t = GetTown(p1); |
1358 |
1358 |
1359 str = AllocateNameUnique((byte*)_decode_parameters, 4); |
1359 str = AllocateNameUnique((byte*)_decode_parameters, 4); |
1360 if (str == 0) |
1360 if (str == 0) |
1361 return CMD_ERROR; |
1361 return CMD_ERROR; |
1362 |
1362 |
1600 SET_EXPENSES_TYPE(EXPENSES_OTHER); |
1600 SET_EXPENSES_TYPE(EXPENSES_OTHER); |
1601 |
1601 |
1602 cost = (_price.build_industry >> 8) * _town_action_costs[p2]; |
1602 cost = (_price.build_industry >> 8) * _town_action_costs[p2]; |
1603 |
1603 |
1604 if (flags & DC_EXEC) { |
1604 if (flags & DC_EXEC) { |
1605 _town_action_proc[p2](DEREF_TOWN(p1), p2); |
1605 _town_action_proc[p2](GetTown(p1), p2); |
1606 InvalidateWindow(WC_TOWN_AUTHORITY, p1); |
1606 InvalidateWindow(WC_TOWN_AUTHORITY, p1); |
1607 } |
1607 } |
1608 |
1608 |
1609 return cost; |
1609 return cost; |
1610 } |
1610 } |
1815 } |
1815 } |
1816 |
1816 |
1817 void InitializeTowns() |
1817 void InitializeTowns() |
1818 { |
1818 { |
1819 Subsidy *s; |
1819 Subsidy *s; |
|
1820 Town *t; |
1820 int i; |
1821 int i; |
1821 |
1822 |
1822 memset(_towns, 0, sizeof(_towns)); |
1823 memset(_towns, 0, sizeof(_towns[0]) * _towns_size); |
1823 for(i=0; i!=lengthof(_towns); i++) |
1824 |
1824 _towns[i].index = i; |
1825 i = 0; |
|
1826 FOR_ALL_TOWNS(t) |
|
1827 t->index = i++; |
1825 |
1828 |
1826 memset(_subsidies, 0, sizeof(_subsidies)); |
1829 memset(_subsidies, 0, sizeof(_subsidies)); |
1827 for (s=_subsidies; s != endof(_subsidies); s++) |
1830 for (s=_subsidies; s != endof(_subsidies); s++) |
1828 s->cargo_type = 0xFF; |
1831 s->cargo_type = 0xFF; |
1829 |
1832 |
1906 |
1909 |
1907 static void Save_TOWN() |
1910 static void Save_TOWN() |
1908 { |
1911 { |
1909 Town *t; |
1912 Town *t; |
1910 |
1913 |
1911 FOR_ALL_TOWNS(t) if (t->xy != 0) { |
1914 FOR_ALL_TOWNS(t) { |
1912 SlSetArrayIndex(t->index); |
1915 if (t->xy != 0) { |
1913 SlObject(t, _town_desc); |
1916 SlSetArrayIndex(t->index); |
|
1917 SlObject(t, _town_desc); |
|
1918 } |
1914 } |
1919 } |
1915 } |
1920 } |
1916 |
1921 |
1917 static void Load_TOWN() |
1922 static void Load_TOWN() |
1918 { |
1923 { |
1919 int index; |
1924 int index; |
1920 while ((index = SlIterateArray()) != -1) { |
1925 while ((index = SlIterateArray()) != -1) { |
1921 Town *t = DEREF_TOWN(index); |
1926 Town *t = GetTown(index); |
|
1927 |
1922 SlObject(t, _town_desc); |
1928 SlObject(t, _town_desc); |
1923 if (index > _total_towns) _total_towns = index; |
1929 if (index > _total_towns) _total_towns = index; |
1924 } |
1930 } |
1925 } |
1931 } |
1926 |
1932 |