equal
deleted
inserted
replaced
1857 if (eflags & BUILDING_2_TILES_X) DoClearTownHouseHelper(tile + TileDiffXY(1, 0)); |
1857 if (eflags & BUILDING_2_TILES_X) DoClearTownHouseHelper(tile + TileDiffXY(1, 0)); |
1858 if (eflags & BUILDING_2_TILES_Y) DoClearTownHouseHelper(tile + TileDiffXY(0, 1)); |
1858 if (eflags & BUILDING_2_TILES_Y) DoClearTownHouseHelper(tile + TileDiffXY(0, 1)); |
1859 if (eflags & BUILDING_HAS_4_TILES) DoClearTownHouseHelper(tile + TileDiffXY(1, 1)); |
1859 if (eflags & BUILDING_HAS_4_TILES) DoClearTownHouseHelper(tile + TileDiffXY(1, 1)); |
1860 } |
1860 } |
1861 |
1861 |
|
1862 static bool IsUniqueTownName(const char *name) |
|
1863 { |
|
1864 const Town *t; |
|
1865 char buf[512]; |
|
1866 |
|
1867 FOR_ALL_TOWNS(t) { |
|
1868 SetDParam(0, t->index); |
|
1869 GetString(buf, STR_TOWN, lastof(buf)); |
|
1870 if (strcmp(buf, name) == 0) return false; |
|
1871 } |
|
1872 |
|
1873 return true; |
|
1874 } |
|
1875 |
1862 /** Rename a town (server-only). |
1876 /** Rename a town (server-only). |
1863 * @param tile unused |
1877 * @param tile unused |
1864 * @param flags type of operation |
1878 * @param flags type of operation |
1865 * @param p1 town ID to rename |
1879 * @param p1 town ID to rename |
1866 * @param p2 unused |
1880 * @param p2 unused |
1868 CommandCost CmdRenameTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1882 CommandCost CmdRenameTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1869 { |
1883 { |
1870 StringID str; |
1884 StringID str; |
1871 Town *t; |
1885 Town *t; |
1872 |
1886 |
1873 if (!IsValidTownID(p1) || _cmd_text[0] == '\0') return CMD_ERROR; |
1887 if (!IsValidTownID(p1) || StrEmpty(_cmd_text)) return CMD_ERROR; |
1874 |
1888 |
1875 t = GetTown(p1); |
1889 t = GetTown(p1); |
1876 |
1890 |
1877 str = AllocateNameUnique(_cmd_text, 4); |
1891 if (!IsUniqueTownName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); |
|
1892 |
|
1893 str = AllocateName(_cmd_text, 4); |
1878 if (str == 0) return CMD_ERROR; |
1894 if (str == 0) return CMD_ERROR; |
1879 |
1895 |
1880 if (flags & DC_EXEC) { |
1896 if (flags & DC_EXEC) { |
1881 DeleteName(t->townnametype); |
1897 DeleteName(t->townnametype); |
1882 t->townnametype = str; |
1898 t->townnametype = str; |
|
1899 t->townnamegrfid = 0; |
1883 |
1900 |
1884 UpdateTownVirtCoord(t); |
1901 UpdateTownVirtCoord(t); |
1885 _town_sort_dirty = true; |
1902 _town_sort_dirty = true; |
1886 UpdateAllStationVirtCoord(); |
1903 UpdateAllStationVirtCoord(); |
1887 MarkWholeScreenDirty(); |
1904 MarkWholeScreenDirty(); |