src/signs.cpp
changeset 9734 eb7fab767c8e
parent 9388 27b62a221d24
child 9914 c07d0352d8d5
equal deleted inserted replaced
9733:94144b73041b 9734:eb7fab767c8e
    22 #include "oldpool_func.h"
    22 #include "oldpool_func.h"
    23 
    23 
    24 #include "table/strings.h"
    24 #include "table/strings.h"
    25 
    25 
    26 SignID _new_sign_id;
    26 SignID _new_sign_id;
    27 bool _sign_sort_dirty;
       
    28 
    27 
    29 /* Initialize the sign-pool */
    28 /* Initialize the sign-pool */
    30 DEFINE_OLD_POOL_GENERIC(Sign, Sign)
    29 DEFINE_OLD_POOL_GENERIC(Sign, Sign)
    31 
    30 
    32 Sign::Sign(PlayerID owner)
    31 Sign::Sign(PlayerID owner)
   109 		si->x = x;
   108 		si->x = x;
   110 		si->y = y;
   109 		si->y = y;
   111 		si->z = GetSlopeZ(x, y);
   110 		si->z = GetSlopeZ(x, y);
   112 		UpdateSignVirtCoords(si);
   111 		UpdateSignVirtCoords(si);
   113 		MarkSignDirty(si);
   112 		MarkSignDirty(si);
   114 		InvalidateWindow(WC_SIGN_LIST, 0);
   113 		InvalidateWindowData(WC_SIGN_LIST, 0, 0);
   115 		_sign_sort_dirty = true;
       
   116 		_new_sign_id = si->index;
   114 		_new_sign_id = si->index;
   117 	}
   115 	}
   118 
   116 
   119 	return CommandCost();
   117 	return CommandCost();
   120 }
   118 }
   146 
   144 
   147 			/* Update; mark sign dirty twice, because it can either becom longer, or shorter */
   145 			/* Update; mark sign dirty twice, because it can either becom longer, or shorter */
   148 			MarkSignDirty(si);
   146 			MarkSignDirty(si);
   149 			UpdateSignVirtCoords(si);
   147 			UpdateSignVirtCoords(si);
   150 			MarkSignDirty(si);
   148 			MarkSignDirty(si);
   151 			InvalidateWindow(WC_SIGN_LIST, 0);
   149 			InvalidateWindowData(WC_SIGN_LIST, 0, 1);
   152 			_sign_sort_dirty = true;
       
   153 		}
   150 		}
   154 	} else { // Delete sign
   151 	} else { // Delete sign
   155 		if (flags & DC_EXEC) {
   152 		if (flags & DC_EXEC) {
   156 			Sign *si = GetSign(p1);
   153 			Sign *si = GetSign(p1);
   157 
   154 
   158 			MarkSignDirty(si);
   155 			MarkSignDirty(si);
   159 			delete si;
   156 			delete si;
   160 
   157 
   161 			InvalidateWindow(WC_SIGN_LIST, 0);
   158 			InvalidateWindowData(WC_SIGN_LIST, 0, 1);
   162 			_sign_sort_dirty = true;
       
   163 		}
   159 		}
   164 	}
   160 	}
   165 
   161 
   166 	return CommandCost();
   162 	return CommandCost();
   167 }
   163 }
   240 	int index;
   236 	int index;
   241 	while ((index = SlIterateArray()) != -1) {
   237 	while ((index = SlIterateArray()) != -1) {
   242 		Sign *si = new (index) Sign();
   238 		Sign *si = new (index) Sign();
   243 		SlObject(si, _sign_desc);
   239 		SlObject(si, _sign_desc);
   244 	}
   240 	}
   245 
       
   246 	_sign_sort_dirty = true;
       
   247 }
   241 }
   248 
   242 
   249 extern const ChunkHandler _sign_chunk_handlers[] = {
   243 extern const ChunkHandler _sign_chunk_handlers[] = {
   250 	{ 'SIGN', Save_SIGN, Load_SIGN, CH_ARRAY | CH_LAST},
   244 	{ 'SIGN', Save_SIGN, Load_SIGN, CH_ARRAY | CH_LAST},
   251 };
   245 };