signs.c
changeset 1835 895203b3a0ea
parent 1820 9b6458526480
child 1837 ebd6a1395d03
equal deleted inserted replaced
1834:33612fb9c7d7 1835:895203b3a0ea
   134  * @param p1 index of the sign to be renamed/removed
   134  * @param p1 index of the sign to be renamed/removed
   135  * @param p2 unused
   135  * @param p2 unused
   136  */
   136  */
   137 int32 CmdRenameSign(int x, int y, uint32 flags, uint32 p1, uint32 p2)
   137 int32 CmdRenameSign(int x, int y, uint32 flags, uint32 p1, uint32 p2)
   138 {
   138 {
   139 	SignStruct *ss;
   139 	/* If _cmd_text != 0 means the new text for the sign is non-empty.
   140 
       
   141 	/* If GetDParam(0) != 0 means the new text for the sign is non-empty.
       
   142 	 * So rename the sign. If it is empty, it has no name, so delete it */
   140 	 * So rename the sign. If it is empty, it has no name, so delete it */
   143 	if (GetDParam(0) != 0) {
   141 	if (_cmd_text != NULL) {
   144 		/* Create the name */
   142 		/* Create the name */
   145 		StringID str = AllocateName(_cmd_text, 0);
   143 		StringID str = AllocateName(_cmd_text, 0);
   146 		if (str == 0) return CMD_ERROR;
   144 		if (str == 0) return CMD_ERROR;
   147 
   145 
   148 		if (flags & DC_EXEC) {
   146 		if (flags & DC_EXEC) {
   149 			ss = GetSign(p1);
   147 			SignStruct *ss = GetSign(p1);
   150 
   148 
   151 			/* Delete the old name */
   149 			/* Delete the old name */
   152 			DeleteName(ss->str);
   150 			DeleteName(ss->str);
   153 			/* Assign the new one */
   151 			/* Assign the new one */
   154 			ss->str = str;
   152 			ss->str = str;
   164 			/* Free the name, because we did not assign it yet */
   162 			/* Free the name, because we did not assign it yet */
   165 			DeleteName(str);
   163 			DeleteName(str);
   166 		}
   164 		}
   167 	} else { /* Delete sign */
   165 	} else { /* Delete sign */
   168 		if (flags & DC_EXEC) {
   166 		if (flags & DC_EXEC) {
   169 			ss = GetSign(p1);
   167 			SignStruct *ss = GetSign(p1);
   170 
   168 
   171 			/* Delete the name */
   169 			/* Delete the name */
   172 			DeleteName(ss->str);
   170 			DeleteName(ss->str);
   173 			ss->str = 0;
   171 			ss->str = 0;
   174 
   172