src/signs.cpp
changeset 10207 c291a21b304e
parent 10156 5f8b021e74d6
child 10208 72c00af5c95d
equal deleted inserted replaced
10206:0050610c0368 10207:c291a21b304e
    26 SignID _new_sign_id;
    26 SignID _new_sign_id;
    27 
    27 
    28 /* Initialize the sign-pool */
    28 /* Initialize the sign-pool */
    29 DEFINE_OLD_POOL_GENERIC(Sign, Sign)
    29 DEFINE_OLD_POOL_GENERIC(Sign, Sign)
    30 
    30 
    31 Sign::Sign(PlayerID owner)
    31 Sign::Sign(Owner owner)
    32 {
    32 {
    33 	this->owner = owner;
    33 	this->owner = owner;
    34 }
    34 }
    35 
    35 
    36 Sign::~Sign()
    36 Sign::~Sign()
    38 	free(this->name);
    38 	free(this->name);
    39 
    39 
    40 	if (CleaningPool()) return;
    40 	if (CleaningPool()) return;
    41 
    41 
    42 	DeleteRenameSignWindow(this->index);
    42 	DeleteRenameSignWindow(this->index);
    43 	this->owner = INVALID_PLAYER;
    43 	this->owner = INVALID_OWNER;
    44 }
    44 }
    45 
    45 
    46 /**
    46 /**
    47  *
    47  *
    48  * Update the coordinate of one sign
    48  * Update the coordinate of one sign
   103 	/* Try to locate a new sign */
   103 	/* Try to locate a new sign */
   104 	if (!Sign::CanAllocateItem()) return_cmd_error(STR_2808_TOO_MANY_SIGNS);
   104 	if (!Sign::CanAllocateItem()) return_cmd_error(STR_2808_TOO_MANY_SIGNS);
   105 
   105 
   106 	/* When we execute, really make the sign */
   106 	/* When we execute, really make the sign */
   107 	if (flags & DC_EXEC) {
   107 	if (flags & DC_EXEC) {
   108 		Sign *si = new Sign(_current_player);
   108 		Sign *si = new Sign(_current_company);
   109 		int x = TileX(tile) * TILE_SIZE;
   109 		int x = TileX(tile) * TILE_SIZE;
   110 		int y = TileY(tile) * TILE_SIZE;
   110 		int y = TileY(tile) * TILE_SIZE;
   111 
   111 
   112 		si->x = x;
   112 		si->x = x;
   113 		si->y = y;
   113 		si->y = y;
   144 
   144 
   145 			/* Delete the old name */
   145 			/* Delete the old name */
   146 			free(si->name);
   146 			free(si->name);
   147 			/* Assign the new one */
   147 			/* Assign the new one */
   148 			si->name = strdup(_cmd_text);
   148 			si->name = strdup(_cmd_text);
   149 			si->owner = _current_player;
   149 			si->owner = _current_company;
   150 
   150 
   151 			/* Update; mark sign dirty twice, because it can either becom longer, or shorter */
   151 			/* Update; mark sign dirty twice, because it can either becom longer, or shorter */
   152 			MarkSignDirty(si);
   152 			MarkSignDirty(si);
   153 			UpdateSignVirtCoords(si);
   153 			UpdateSignVirtCoords(si);
   154 			MarkSignDirty(si);
   154 			MarkSignDirty(si);