signs.c
changeset 1165 8fa7d3e235c6
parent 1093 4fdc46eaf423
child 1171 f97bbe5487a9
equal deleted inserted replaced
1164:48da7bcf7b7c 1165:8fa7d3e235c6
    65 
    65 
    66 /**
    66 /**
    67  *
    67  *
    68  * Place a sign at the given x/y
    68  * Place a sign at the given x/y
    69  *
    69  *
    70  * @param p1 not used
    70  * @param p1 player number
    71  * @param p2 not used
    71  * @param p2 not used
    72  */
    72  */
    73 int32 CmdPlaceSign(int x, int y, uint32 flags, uint32 p1, uint32 p2)
    73 int32 CmdPlaceSign(int x, int y, uint32 flags, uint32 p1, uint32 p2)
    74 {
    74 {
    75 	SignStruct *ss;
    75 	SignStruct *ss;
    82 	/* When we execute, really make the sign */
    82 	/* When we execute, really make the sign */
    83 	if (flags & DC_EXEC) {
    83 	if (flags & DC_EXEC) {
    84 		ss->str = STR_280A_SIGN;
    84 		ss->str = STR_280A_SIGN;
    85 		ss->x = x;
    85 		ss->x = x;
    86 		ss->y = y;
    86 		ss->y = y;
       
    87 		ss->owner = p1;
    87 		ss->z = GetSlopeZ(x,y);
    88 		ss->z = GetSlopeZ(x,y);
    88 		UpdateSignVirtCoords(ss);
    89 		UpdateSignVirtCoords(ss);
    89 		MarkSignDirty(ss);
    90 		MarkSignDirty(ss);
    90 		_new_sign_struct = ss;
    91 		_new_sign_struct = ss;
    91 	}
    92 	}
    95 
    96 
    96 /**
    97 /**
    97  * Rename a sign
    98  * Rename a sign
    98  *
    99  *
    99  * @param sign_id Index of the sign
   100  * @param sign_id Index of the sign
   100  * @param remove  If 1, sign will be removed
   101  * @param new owner, if OWNER_NONE, sign will be removed
   101  */
   102  */
   102 int32 CmdRenameSign(int x, int y, uint32 flags, uint32 sign_id, uint32 remove)
   103 int32 CmdRenameSign(int x, int y, uint32 flags, uint32 sign_id, uint32 owner)
   103 {
   104 {
   104 	StringID str;
   105 	StringID str;
   105 	SignStruct *ss;
   106 	SignStruct *ss;
   106 
   107 
   107 	/* If GetDParam(0) == nothing, we delete the sign */
   108 	/* If GetDParam(0) == nothing, we delete the sign */
   108 	if (GetDParam(0) != 0 && remove != 1) {
   109 	if (GetDParam(0) != 0 && owner != OWNER_NONE) {
   109 		/* Create the name */
   110 		/* Create the name */
   110 		str = AllocateName((byte*)_decode_parameters, 0);
   111 		str = AllocateName((byte*)_decode_parameters, 0);
   111 		if (str == 0)
   112 		if (str == 0)
   112 			return CMD_ERROR;
   113 			return CMD_ERROR;
   113 
   114 
   118 
   119 
   119 			/* Delete the old name */
   120 			/* Delete the old name */
   120 			DeleteName(ss->str);
   121 			DeleteName(ss->str);
   121 			/* Assign the new one */
   122 			/* Assign the new one */
   122 			ss->str = str;
   123 			ss->str = str;
       
   124 			ss->owner = owner;
   123 
   125 
   124 			/* Update */
   126 			/* Update */
   125 			UpdateSignVirtCoords(ss);
   127 			UpdateSignVirtCoords(ss);
   126 			MarkSignDirty(ss);
   128 			MarkSignDirty(ss);
   127 		} else {
   129 		} else {
   163  *  sign-tool is selected
   165  *  sign-tool is selected
   164  *
   166  *
   165  */
   167  */
   166 void PlaceProc_Sign(uint tile)
   168 void PlaceProc_Sign(uint tile)
   167 {
   169 {
   168 	DoCommandP(tile, 0, 0, CcPlaceSign, CMD_PLACE_SIGN | CMD_MSG(STR_2809_CAN_T_PLACE_SIGN_HERE));
   170 	DoCommandP(tile, _current_player, 0, CcPlaceSign, CMD_PLACE_SIGN | CMD_MSG(STR_2809_CAN_T_PLACE_SIGN_HERE));
   169 }
   171 }
   170 
   172 
   171 /**
   173 /**
   172  *
   174  *
   173  * Initialize the signs
   175  * Initialize the signs
   189 	SLE_VAR(SignStruct,str,						SLE_UINT16),
   191 	SLE_VAR(SignStruct,str,						SLE_UINT16),
   190 	SLE_CONDVAR(SignStruct,x,					SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
   192 	SLE_CONDVAR(SignStruct,x,					SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
   191 	SLE_CONDVAR(SignStruct,y,					SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
   193 	SLE_CONDVAR(SignStruct,y,					SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
   192 	SLE_CONDVAR(SignStruct,x,					SLE_INT32, 5, 255),
   194 	SLE_CONDVAR(SignStruct,x,					SLE_INT32, 5, 255),
   193 	SLE_CONDVAR(SignStruct,y,					SLE_INT32, 5, 255),
   195 	SLE_CONDVAR(SignStruct,y,					SLE_INT32, 5, 255),
       
   196 // 	SLE_CONDVAR(SignStruct,owner,			SLE_INT32, 6, 255), // TODO: uncomment this after the savegame bump to version 6.0
   194 	SLE_VAR(SignStruct,z,							SLE_UINT8),
   197 	SLE_VAR(SignStruct,z,							SLE_UINT8),
   195 	SLE_END()
   198 	SLE_END()
   196 };
   199 };
   197 
   200 
   198 /**
   201 /**