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; |