signs.c
changeset 3491 35d747bb5e82
parent 3047 2880aef0ee9d
child 3585 43461f26b729
equal deleted inserted replaced
3490:d53bc3e794bd 3491:35d747bb5e82
   102 }
   102 }
   103 
   103 
   104 /** Place a sign at the given coordinates. Ownership of sign has
   104 /** Place a sign at the given coordinates. Ownership of sign has
   105  * no effect whatsoever except for the colour the sign gets for easy recognition,
   105  * no effect whatsoever except for the colour the sign gets for easy recognition,
   106  * but everybody is able to rename/remove it.
   106  * but everybody is able to rename/remove it.
   107  * @param x,y coordinates to place sign at
   107  * @param tile tile to place sign at
   108  * @param p1 unused
   108  * @param p1 unused
   109  * @param p2 unused
   109  * @param p2 unused
   110  */
   110  */
   111 int32 CmdPlaceSign(int x, int y, uint32 flags, uint32 p1, uint32 p2)
   111 int32 CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   112 {
   112 {
   113 	SignStruct *ss;
   113 	SignStruct *ss;
   114 
   114 
   115 	/* Try to locate a new sign */
   115 	/* Try to locate a new sign */
   116 	ss = AllocateSign();
   116 	ss = AllocateSign();
   117 	if (ss == NULL) return_cmd_error(STR_2808_TOO_MANY_SIGNS);
   117 	if (ss == NULL) return_cmd_error(STR_2808_TOO_MANY_SIGNS);
   118 
   118 
   119 	/* When we execute, really make the sign */
   119 	/* When we execute, really make the sign */
   120 	if (flags & DC_EXEC) {
   120 	if (flags & DC_EXEC) {
       
   121 		int x = TileX(tile) * TILE_SIZE;
       
   122 		int y = TileY(tile) * TILE_SIZE;
       
   123 
   121 		ss->str = STR_280A_SIGN;
   124 		ss->str = STR_280A_SIGN;
   122 		ss->x = x;
   125 		ss->x = x;
   123 		ss->y = y;
   126 		ss->y = y;
   124 		ss->owner = _current_player; // owner of the sign; just eyecandy
   127 		ss->owner = _current_player; // owner of the sign; just eyecandy
   125 		ss->z = GetSlopeZ(x,y);
   128 		ss->z = GetSlopeZ(x,y);
   134 }
   137 }
   135 
   138 
   136 /** Rename a sign. If the new name of the sign is empty, we assume
   139 /** Rename a sign. If the new name of the sign is empty, we assume
   137  * the user wanted to delete it. So delete it. Ownership of signs
   140  * the user wanted to delete it. So delete it. Ownership of signs
   138  * has no meaning/effect whatsoever except for eyecandy
   141  * has no meaning/effect whatsoever except for eyecandy
   139  * @param x,y unused
   142  * @param tile unused
   140  * @param p1 index of the sign to be renamed/removed
   143  * @param p1 index of the sign to be renamed/removed
   141  * @param p2 unused
   144  * @param p2 unused
   142  */
   145  */
   143 int32 CmdRenameSign(int x, int y, uint32 flags, uint32 p1, uint32 p2)
   146 int32 CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   144 {
   147 {
   145 	if (!IsSignIndex(p1)) return CMD_ERROR;
   148 	if (!IsSignIndex(p1)) return CMD_ERROR;
   146 
   149 
   147 	/* If _cmd_text 0 means the new text for the sign is non-empty.
   150 	/* If _cmd_text 0 means the new text for the sign is non-empty.
   148 	 * So rename the sign. If it is empty, it has no name, so delete it */
   151 	 * So rename the sign. If it is empty, it has no name, so delete it */