equal
deleted
inserted
replaced
3 /** @file ai_object.cpp handles the commands-related functions of the AIObject class */ |
3 /** @file ai_object.cpp handles the commands-related functions of the AIObject class */ |
4 |
4 |
5 #include "ai_object.hpp" |
5 #include "ai_object.hpp" |
6 #include "../../command.h" |
6 #include "../../command.h" |
7 #include "../../player.h" |
7 #include "../../player.h" |
|
8 #include "table/strings.h" // for signs.h |
|
9 #include "../../signs.h" // for _new_sign_id |
8 #include "../ai.h" |
10 #include "../ai.h" |
9 #include "../ai_threads.h" |
11 #include "../ai_threads.h" |
10 |
12 |
11 void AIObject::SetDoCommandDelay(uint ticks) |
13 void AIObject::SetDoCommandDelay(uint ticks) |
12 { |
14 { |
56 } |
58 } |
57 |
59 |
58 VehicleID AIObject::GetNewVehicleID() |
60 VehicleID AIObject::GetNewVehicleID() |
59 { |
61 { |
60 return AIObject::GetDoCommandStruct(_current_player)->new_vehicle_id; |
62 return AIObject::GetDoCommandStruct(_current_player)->new_vehicle_id; |
|
63 } |
|
64 |
|
65 void AIObject::SetNewSignID(SignID sign) |
|
66 { |
|
67 AIObject::GetDoCommandStruct(_current_player)->new_sign_id = sign; |
|
68 } |
|
69 |
|
70 SignID AIObject::GetNewSignID() |
|
71 { |
|
72 return AIObject::GetDoCommandStruct(_current_player)->new_sign_id; |
61 } |
73 } |
62 |
74 |
63 AIObject::AIDoCommandStruct *AIObject::GetDoCommandStruct(PlayerID player) |
75 AIObject::AIDoCommandStruct *AIObject::GetDoCommandStruct(PlayerID player) |
64 { |
76 { |
65 /* Storage for data on per-AI level */ |
77 /* Storage for data on per-AI level */ |
128 #endif |
140 #endif |
129 /* For SinglePlayer we execute the command immediatly */ |
141 /* For SinglePlayer we execute the command immediatly */ |
130 ::DoCommandP(tile, p1, p2, NULL, procc); |
142 ::DoCommandP(tile, p1, p2, NULL, procc); |
131 /* Store some values inside the AIObject static memory */ |
143 /* Store some values inside the AIObject static memory */ |
132 AIObject::SetNewVehicleID(_new_vehicle_id); |
144 AIObject::SetNewVehicleID(_new_vehicle_id); |
|
145 AIObject::SetNewSignID(_new_sign_id); |
133 |
146 |
134 /* Suspend the AI player for 1 tick, so it simulates MultiPlayer */ |
147 /* Suspend the AI player for 1 tick, so it simulates MultiPlayer */ |
135 AI_SuspendPlayer(_current_player, AIObject::GetDoCommandDelay()); |
148 AI_SuspendPlayer(_current_player, AIObject::GetDoCommandDelay()); |
136 } |
149 } |
137 |
150 |