town_cmd.c
changeset 543 946badd71033
parent 534 306bc86eb23e
child 679 04ca2cd69420
equal deleted inserted replaced
542:de27e74b11bd 543:946badd71033
    11 #include "player.h"
    11 #include "player.h"
    12 #include "news.h"
    12 #include "news.h"
    13 #include "saveload.h"
    13 #include "saveload.h"
    14 #include "economy.h"
    14 #include "economy.h"
    15 #include "gui.h"
    15 #include "gui.h"
       
    16 #include "network.h"
    16 
    17 
    17 enum {
    18 enum {
    18 	TOWN_HAS_CHURCH     = 0x02,
    19 	TOWN_HAS_CHURCH     = 0x02,
    19 	TOWN_HAS_STADIUM    = 0x04
    20 	TOWN_HAS_STADIUM    = 0x04
    20 };
    21 };
   926 static Town *AllocateTown()
   927 static Town *AllocateTown()
   927 {
   928 {
   928 	Town *t;
   929 	Town *t;
   929 	FOR_ALL_TOWNS(t) {
   930 	FOR_ALL_TOWNS(t) {
   930 		if (t->xy == 0) {
   931 		if (t->xy == 0) {
   931 			_total_towns++;
   932 			if (t->index > _total_towns) _total_towns = t->index;
   932 			return t;
   933 			return t;
   933 		}
   934 		}
   934 	}
   935 	}
   935 	return NULL;
   936 	return NULL;
   936 }
   937 }
  1340 int32 CmdRenameTown(int x, int y, uint32 flags, uint32 p1, uint32 p2)
  1341 int32 CmdRenameTown(int x, int y, uint32 flags, uint32 p1, uint32 p2)
  1341 {
  1342 {
  1342 	StringID str;
  1343 	StringID str;
  1343 	Town *t = DEREF_TOWN(p1);
  1344 	Town *t = DEREF_TOWN(p1);
  1344 
  1345 
  1345 	str = AllocateName((byte*)_decode_parameters, 4);
  1346 	str = AllocateNameUnique((byte*)_decode_parameters, 4);
  1346 	if (str == 0)
  1347 	if (str == 0)
  1347 		return CMD_ERROR;
  1348 		return CMD_ERROR;
  1348 
  1349 
  1349 	if (flags & DC_EXEC) {
  1350 	if (flags & DC_EXEC) {
  1350 		StringID old_str = t->townnametype;
  1351 		StringID old_str = t->townnametype;
  1908 {
  1909 {
  1909 	int index;
  1910 	int index;
  1910 	while ((index = SlIterateArray()) != -1) {
  1911 	while ((index = SlIterateArray()) != -1) {
  1911 		Town *t = DEREF_TOWN(index);
  1912 		Town *t = DEREF_TOWN(index);
  1912 		SlObject(t, _town_desc);
  1913 		SlObject(t, _town_desc);
  1913 		_total_towns++;
  1914 		if (index > _total_towns) _total_towns = index;
  1914 	}
  1915 	}
  1915 }
  1916 }
  1916 
  1917 
  1917 void AfterLoadTown()
  1918 void AfterLoadTown()
  1918 {
  1919 {