Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.49 KB | None | 0 0
  1. diff --git a/src/client/campaign/cp_employee.c b/src/client/campaign/cp_employee.c
  2. index cd71f4d..4227ba7 100644
  3. --- a/src/client/campaign/cp_employee.c
  4. +++ b/src/client/campaign/cp_employee.c
  5. @@ -56,7 +56,7 @@ employee_t* E_GetNextFromBase (employeeType_t type, employee_t *lastEmployee, co
  6. {
  7. employee_t* employee = lastEmployee;
  8.  
  9. - while ((employee = E_GetNext(type, employee))) {
  10. + while ((employee = E_GetNext(type, employee)) != NULL) {
  11. if (E_IsInBase(employee, base))
  12. break;
  13. }
  14. @@ -82,7 +82,7 @@ employee_t* E_GetNextHired (employeeType_t type, employee_t *lastEmployee)
  15. {
  16. employee_t* employee = lastEmployee;
  17.  
  18. - while ((employee = E_GetNext(type, employee))) {
  19. + while ((employee = E_GetNext(type, employee)) != NULL) {
  20. if (E_IsHired(employee))
  21. break;
  22. }
  23. @@ -290,12 +290,13 @@ void E_ResetEmployees (void)
  24. */
  25. employee_t* E_GetEmployeeByIDX (employeeType_t type, int idx)
  26. {
  27. - employee_t *employee = NULL;
  28. + employee_t *employee;
  29.  
  30. if (type >= MAX_EMPL || idx < 0)
  31. return NULL;
  32.  
  33. - while ((employee = E_GetNext(type, employee))) {
  34. + employee = NULL;
  35. + while ((employee = E_GetNext(type, employee)) != NULL) {
  36. if (employee->idx == idx)
  37. return employee;
  38. }
  39. @@ -312,12 +313,13 @@ employee_t* E_GetEmployeeByIDX (employeeType_t type, int idx)
  40. */
  41. employee_t* E_GetEmployee (const base_t* const base, employeeType_t type, int idx)
  42. {
  43. - employee_t *employee = NULL;
  44. + employee_t *employee;
  45.  
  46. if (!base || type >= MAX_EMPL || idx < 0)
  47. return NULL;
  48.  
  49. - while ((employee = E_GetNext(type, employee))) {
  50. + employee = NULL;
  51. + while ((employee = E_GetNext(type, employee)) != NULL) {
  52. if (employee->idx == idx && (!E_IsHired(employee) || E_IsInBase(employee, base)))
  53. return employee;
  54. }
  55. @@ -337,14 +339,15 @@ employee_t* E_GetEmployee (const base_t* const base, employeeType_t type, int id
  56. static employee_t* E_GetUnhiredEmployee (employeeType_t type, int idx)
  57. {
  58. int j = -1; /* The number of found unhired employees. Ignore the minus. */
  59. - employee_t *employee = NULL;
  60. + employee_t *employee;
  61.  
  62. if (type >= MAX_EMPL) {
  63. Com_Printf("E_GetUnhiredEmployee: Unknown EmployeeType: %i\n", type);
  64. return NULL;
  65. }
  66.  
  67. - while ((employee = E_GetNext(type, employee))) {
  68. + employee = NULL;
  69. + while ((employee = E_GetNext(type, employee)) != NULL) {
  70. if (employee->idx == idx) {
  71. if (E_IsHired(employee)) {
  72. Com_Printf("E_GetUnhiredEmployee: Warning: employee is already hired!\n");
  73. @@ -371,7 +374,7 @@ employee_t* E_GetUnhiredRobot (const ugv_t *ugvType)
  74. {
  75. employee_t *employee = NULL;
  76.  
  77. - while ((employee = E_GetNext(EMPL_ROBOT, employee))) {
  78. + while ((employee = E_GetNext(EMPL_ROBOT, employee)) != NULL) {
  79. if (!E_IsHired(employee)) {
  80. /* If no type was given we return the first ugv we find. */
  81. if (!ugvType || employee->ugv == ugvType)
  82. @@ -402,7 +405,7 @@ int E_GetHiredEmployees (const base_t* const base, employeeType_t type, linkedLi
  83. LIST_Delete(hiredEmployees);
  84.  
  85. employee = NULL;
  86. - while ((employee = E_GetNextHired(type, employee))) {
  87. + while ((employee = E_GetNextHired(type, employee)) != NULL) {
  88. if (!employee->transfer && (!base || E_IsInBase(employee, base))) {
  89. LIST_AddPointer(hiredEmployees, employee);
  90. }
  91. @@ -475,7 +478,8 @@ static inline qboolean E_EmployeeIsUnassigned (const employee_t * employee)
  92. employee_t* E_GetAssignedEmployee (const base_t* const base, const employeeType_t type)
  93. {
  94. employee_t *employee = NULL;
  95. - while ((employee = E_GetNextFromBase(type, employee, base))) {
  96. +
  97. + while ((employee = E_GetNextFromBase(type, employee, base)) != NULL) {
  98. if (!E_EmployeeIsUnassigned(employee))
  99. return employee;
  100. }
  101. @@ -493,7 +497,8 @@ employee_t* E_GetAssignedEmployee (const base_t* const base, const employeeType_
  102. employee_t* E_GetUnassignedEmployee (const base_t* const base, const employeeType_t type)
  103. {
  104. employee_t *employee = NULL;
  105. - while ((employee = E_GetNextFromBase(type, employee, base))) {
  106. +
  107. + while ((employee = E_GetNextFromBase(type, employee, base)) != NULL) {
  108. if (E_EmployeeIsUnassigned(employee))
  109. return employee;
  110. }
  111. @@ -642,7 +647,7 @@ void E_UnhireAllEmployees (base_t* base, employeeType_t type)
  112. assert(type < MAX_EMPL);
  113.  
  114. employee = NULL;
  115. - while ((employee = E_GetNextFromBase(type, employee, base))) {
  116. + while ((employee = E_GetNextFromBase(type, employee, base)) != NULL) {
  117. E_UnhireEmployee(employee);
  118. }
  119. }
  120. @@ -771,18 +776,14 @@ void E_DeleteAllEmployees (base_t* base)
  121. employeeType_t type;
  122.  
  123. for (type = EMPL_SOLDIER; type < MAX_EMPL; type++) {
  124. + employee_t *lastEmployee = NULL;
  125. employee_t *employee = NULL;
  126. - for (;;) {
  127. - employee = E_GetNext(type, employee);
  128. - if (employee == NULL)
  129. - break;
  130. - if (base == NULL || E_IsInBase(employee, base)) {
  131. - /** @todo restart the iterator until we've found a better solution
  132. - * this is needed because the employee pointer is no longer valid and can't
  133. - * be used as a base to get the next one */
  134. - if (E_DeleteEmployee(employee))
  135. - employee = NULL;
  136. - }
  137. +
  138. + while ((employee = E_GetNext(type, employee)) != NULL) {
  139. + if ((base == NULL || E_IsInBase(employee, base)) && E_DeleteEmployee(employee))
  140. + employee = lastEmployee;
  141. + else
  142. + lastEmployee = employee;
  143. }
  144. }
  145. }
  146. @@ -806,22 +807,21 @@ void E_DeleteEmployeesExceedingCapacity (base_t *base)
  147.  
  148. /* do a reverse loop in order to finish by soldiers (the most important employees) */
  149. for (type = MAX_EMPL - 1; type >= 0; type--) {
  150. - employee_t *employee = NULL;
  151. + employee_t *employee;
  152. + employee_t *lastEmployee;
  153.  
  154. /* UGV are not stored in Quarters */
  155. if (type == EMPL_ROBOT)
  156. continue;
  157.  
  158. - while ((employee = E_GetNext(type, employee))) {
  159. - /* check if the employee is hired on this base */
  160. - if (!E_IsInBase(employee, base))
  161. - continue;
  162. + employee = NULL;
  163. + lastEmployee = NULL;
  164. + while ((employee = E_GetNext(type, employee)) != NULL) {
  165. + if (E_IsInBase(employee, base) && E_DeleteEmployee(employee))
  166. + employee = lastEmployee;
  167. + else
  168. + lastEmployee = employee;
  169.  
  170. - /** @todo restart the iterator until we've found a better solution
  171. - * this is needed because the employee pointer is no longer valid and can't
  172. - * be used as a base to get the next one */
  173. - if (E_DeleteEmployee(employee))
  174. - employee = NULL;
  175. if (base->capacities[CAP_EMPLOYEES].cur <= base->capacities[CAP_EMPLOYEES].max)
  176. return;
  177. }
  178. @@ -843,7 +843,8 @@ void E_RefreshUnhiredEmployeeGlobalList (const employeeType_t type, const qboole
  179. const nation_t *happyNations[MAX_NATIONS];
  180. int numHappyNations = 0;
  181. int idx, nationIdx;
  182. - employee_t *employee = NULL;
  183. + employee_t *lastEmployee;
  184. + employee_t *employee;
  185.  
  186. happyNations[0] = NULL;
  187. /* get a list of nations, if excludeHappyNations is qtrue then also exclude
  188. @@ -863,15 +864,18 @@ void E_RefreshUnhiredEmployeeGlobalList (const employeeType_t type, const qboole
  189. nationIdx = 0;
  190. /* Fill the global data employee list with employees, evenly distributed
  191. * between nations in the happyNations list */
  192. - while ((employee = E_GetNext(type, employee))) {
  193. + employee = NULL;
  194. + lastEmployee = NULL;
  195. + while ((employee = E_GetNext(type, employee)) != NULL) {
  196. /* we don't want to overwrite employees that have already been hired */
  197. if (!E_IsHired(employee)) {
  198. - /** @todo this is not working, employee can't be used as a
  199. - * base to get the next employee - but we can't set it to NULL
  200. - * because this while would loop endless */
  201. E_DeleteEmployee(employee);
  202. E_CreateEmployee(type, happyNations[nationIdx], NULL);
  203. nationIdx = (nationIdx + 1) % numHappyNations;
  204. + /* continue iteration from the last employee, this one is deleted */
  205. + employee = lastEmployee;
  206. + } else {
  207. + lastEmployee = employee;
  208. }
  209. }
  210. }
  211. @@ -944,7 +948,7 @@ int E_CountHired (const base_t* const base, employeeType_t type)
  212. int count = 0;
  213. employee_t *employee = NULL;
  214.  
  215. - while ((employee = E_GetNextHired(type, employee))) {
  216. + while ((employee = E_GetNextHired(type, employee)) != NULL) {
  217. if (!base || E_IsInBase(employee, base))
  218. count++;
  219. }
  220. @@ -962,7 +966,7 @@ int E_CountHiredRobotByType (const base_t* const base, const ugv_t *ugvType)
  221. int count = 0;
  222. employee_t *employee = NULL;
  223.  
  224. - while ((employee = E_GetNextHired(EMPL_ROBOT, employee))) {
  225. + while ((employee = E_GetNextHired(EMPL_ROBOT, employee)) != NULL) {
  226. if (employee->ugv == ugvType && (!base || E_IsInBase(employee, base)))
  227. count++;
  228. }
  229. @@ -1001,7 +1005,8 @@ int E_CountUnhired (employeeType_t type)
  230. {
  231. int count = 0;
  232. employee_t *employee = NULL;
  233. - while ((employee = E_GetNext(type, employee))) {
  234. +
  235. + while ((employee = E_GetNext(type, employee)) != NULL) {
  236. if (!E_IsHired(employee))
  237. count++;
  238. }
  239. @@ -1018,7 +1023,7 @@ int E_CountUnhiredRobotsByType (const ugv_t *ugvType)
  240. int count = 0;
  241. employee_t *employee = NULL;
  242.  
  243. - while ((employee = E_GetNext(EMPL_ROBOT, employee))) {
  244. + while ((employee = E_GetNext(EMPL_ROBOT, employee)) != NULL) {
  245. if (!E_IsHired(employee) && employee->ugv == ugvType)
  246. count++;
  247. }
  248. @@ -1040,7 +1045,7 @@ int E_CountUnassigned (const base_t* const base, employeeType_t type)
  249.  
  250. count = 0;
  251. employee = NULL;
  252. - while ((employee = E_GetNextFromBase(type, employee, base))) {
  253. + while ((employee = E_GetNextFromBase(type, employee, base)) != NULL) {
  254. if (E_EmployeeIsUnassigned(employee))
  255. count++;
  256. }
  257. @@ -1094,7 +1099,7 @@ static void E_ListHired_f (void)
  258.  
  259. for (emplType = 0; emplType < MAX_EMPL; emplType++) {
  260. employee_t *employee = NULL;
  261. - while ((employee = E_GetNextHired(emplType, employee))) {
  262. + while ((employee = E_GetNextHired(emplType, employee)) != NULL) {
  263. Com_Printf("Employee: %s (idx: %i) %s at %s\n", E_GetEmployeeString(employee->type), employee->idx,
  264. employee->chr.name, employee->baseHired->name);
  265. if (employee->type != emplType)
  266. @@ -1127,7 +1132,7 @@ employee_t* E_GetEmployeeFromChrUCN (int uniqueCharacterNumber)
  267. /* MAX_EMPLOYEES and not numWholeTeam - maybe some other soldier died */
  268. for (j = 0; j < MAX_EMPL; j++) {
  269. employee_t *employee = NULL;
  270. - while ((employee = E_GetNext(j, employee))) {
  271. + while ((employee = E_GetNext(j, employee)) != NULL) {
  272. if (employee->chr.ucn == uniqueCharacterNumber)
  273. return employee;
  274. }
  275. @@ -1148,33 +1153,33 @@ employee_t* E_GetEmployeeFromChrUCN (int uniqueCharacterNumber)
  276. */
  277. qboolean E_SaveXML (mxml_node_t *p)
  278. {
  279. - employeeType_t j;
  280. + employeeType_t emplType;
  281.  
  282. Com_RegisterConstList(saveEmployeeConstants);
  283. - for (j = 0; j < MAX_EMPL; j++) {
  284. + for (emplType = 0; emplType < MAX_EMPL; emplType++) {
  285. mxml_node_t *snode = mxml_AddNode(p, SAVE_EMPLOYEE_EMPLOYEES);
  286. - employee_t *e = NULL;
  287. + employee_t *employee = NULL;
  288.  
  289. - mxml_AddString(snode, SAVE_EMPLOYEE_TYPE, Com_GetConstVariable(SAVE_EMPLOYEETYPE_NAMESPACE, j));
  290. - while ((e = E_GetNext(j, e))) {
  291. + mxml_AddString(snode, SAVE_EMPLOYEE_TYPE, Com_GetConstVariable(SAVE_EMPLOYEETYPE_NAMESPACE, emplType));
  292. + while ((employee = E_GetNext(emplType, employee)) != NULL) {
  293. mxml_node_t * chrNode;
  294. mxml_node_t *ssnode = mxml_AddNode(snode, SAVE_EMPLOYEE_EMPLOYEE);
  295.  
  296. /** @note e->transfer is not saved here because it'll be restored via TR_Load. */
  297. - mxml_AddInt(ssnode, SAVE_EMPLOYEE_IDX, e->idx);
  298. - if (e->baseHired)
  299. - mxml_AddInt(ssnode, SAVE_EMPLOYEE_BASEHIRED, e->baseHired->idx);
  300. - if (e->assigned)
  301. - mxml_AddBool(ssnode, SAVE_EMPLOYEE_ASSIGNED, e->assigned);
  302. + mxml_AddInt(ssnode, SAVE_EMPLOYEE_IDX, employee->idx);
  303. + if (employee->baseHired)
  304. + mxml_AddInt(ssnode, SAVE_EMPLOYEE_BASEHIRED, employee->baseHired->idx);
  305. + if (employee->assigned)
  306. + mxml_AddBool(ssnode, SAVE_EMPLOYEE_ASSIGNED, employee->assigned);
  307. /* Store the nations identifier string. */
  308. - assert(e->nation);
  309. - mxml_AddString(ssnode, SAVE_EMPLOYEE_NATION, e->nation->id);
  310. + assert(employee->nation);
  311. + mxml_AddString(ssnode, SAVE_EMPLOYEE_NATION, employee->nation->id);
  312. /* Store the ugv-type identifier string. (Only exists for EMPL_ROBOT). */
  313. - if (e->ugv)
  314. - mxml_AddString(ssnode, SAVE_EMPLOYEE_UGV, e->ugv->id);
  315. + if (employee->ugv)
  316. + mxml_AddString(ssnode, SAVE_EMPLOYEE_UGV, employee->ugv->id);
  317. /* Character Data */
  318. chrNode = mxml_AddNode(ssnode, SAVE_EMPLOYEE_CHR);
  319. - CL_SaveCharacterXML(chrNode, &e->chr);
  320. + CL_SaveCharacterXML(chrNode, &employee->chr);
  321. }
  322. }
  323. Com_UnregisterConstList(saveEmployeeConstants);
  324. diff --git a/src/client/campaign/cp_missions.c b/src/client/campaign/cp_missions.c
  325. index de4c000..7abe5fd 100644
  326. --- a/src/client/campaign/cp_missions.c
  327. +++ b/src/client/campaign/cp_missions.c
  328. @@ -1215,7 +1215,8 @@ void CP_MissionEnd (const campaign_t *campaign, mission_t* mission, const battle
  329. base_t *base;
  330. aircraft_t *aircraft;
  331. int numberOfSoldiers = 0; /* DEBUG */
  332. - employee_t *employee = NULL;
  333. + employee_t *employee;
  334. + employee_t *lastEmployee;
  335.  
  336. if (mission->stage == STAGE_BASE_ATTACK) {
  337. base = mission->data.base;
  338. @@ -1241,21 +1242,17 @@ void CP_MissionEnd (const campaign_t *campaign, mission_t* mission, const battle
  339. /* update stats */
  340. CL_UpdateCharacterStats(base, aircraft);
  341.  
  342. + employee = NULL;
  343. + lastEmployee = NULL;
  344. while ((employee = E_GetNext(EMPL_SOLDIER, employee))) {
  345. if (AIR_IsEmployeeInAircraft(employee, aircraft))
  346. numberOfSoldiers++;
  347.  
  348. - if (E_IsInBase(employee, base)) {
  349. - const character_t *chr = &(employee->chr);
  350. - /* if employee is marked as dead */
  351. - if (chr->HP <= 0) { /** @todo <= -50, etc. (implants) */
  352. - /** @todo restart the iterator until we've found a better solution
  353. - * this is needed because the employee pointer is no longer valid and can't
  354. - * be used as a base to get the next one */
  355. - if (E_DeleteEmployee(employee))
  356. - employee = NULL;
  357. - }
  358. - }
  359. + /** @todo replace HP check with some CHRSH->IsDead() function */
  360. + if (E_IsInBase(employee, base) && (employee->chr.HP <= 0) && E_DeleteEmployee(employee))
  361. + employee = lastEmployee;
  362. + else
  363. + lastEmployee = employee;
  364. }
  365. Com_DPrintf(DEBUG_CLIENT, "CP_MissionEnd - num %i\n", numberOfSoldiers);
  366.  
  367. diff --git a/src/client/campaign/cp_transfer.c b/src/client/campaign/cp_transfer.c
  368. index 674cefc..0177bff 100644
  369. --- a/src/client/campaign/cp_transfer.c
  370. +++ b/src/client/campaign/cp_transfer.c
  371. @@ -58,6 +58,37 @@ transfer_t* TR_GetNext (transfer_t *lastTransfer)
  372. }
  373.  
  374. /**
  375. + * @brief Returns the next transfered employee of a transfer session
  376. + * @param[in] transfer Pointer to the transfersession to check
  377. + * @param[in] type The employee type to query
  378. + * @param[in] lastEmployee Pointer to the last employee to iterate from. call with NULL for the first
  379. + * @returns NULL, if transfer parameter is NULL or there is no more employee in the transfer, or the pointer of the next employee otherwise
  380. + */
  381. +employee_t* TR_GetNextEmployee (transfer_t *transfer, employeeType_t type, employee_t *lastEmployee)
  382. +{
  383. + if (!transfer)
  384. + return NULL;
  385. + if (type == MAX_EMPL)
  386. + return NULL;
  387. +
  388. + return (employee_t*) LIST_GetNext(transfer->employees[type], (void*) lastEmployee);
  389. +}
  390. +
  391. +/**
  392. + * @brief Returns the next transfered aircraft of a transfer session
  393. + * @param[in] transfer Pointer to the transfersession to check
  394. + * @param[in] lastAircraft Pointer to the last aircraft to iterate from. call with NULL for the first
  395. + * @returns NULL, if transfer parameter is NULL or there is no more aircraft in the transfer, or the pointer of the next aircraft otherwise
  396. + */
  397. +aircraft_t* TR_GetNextAircraft (transfer_t *transfer, aircraft_t *lastAircraft)
  398. +{
  399. + if (!transfer)
  400. + return NULL;
  401. +
  402. + return (aircraft_t*) LIST_GetNext(transfer->aircraft, (void*) lastAircraft);
  403. +}
  404. +
  405. +/**
  406. * @brief Unloads transfer cargo when finishing the transfer or destroys it when no buildings/base.
  407. * @param[in,out] destination The destination base - might be NULL in case the base
  408. * is already destroyed
  409. @@ -101,24 +132,24 @@ static void TR_EmptyTransferCargo (base_t *destination, transfer_t *transfer, qb
  410.  
  411. if (transfer->hasEmployees && transfer->srcBase) { /* Employees. (cannot come from a mission) */
  412. if (!success || !B_GetBuildingStatus(destination, B_QUARTERS)) { /* Employees will be unhired. */
  413. - int i;
  414. + employeeType_t i;
  415. if (success) {
  416. Com_sprintf(cp_messageBuffer, sizeof(cp_messageBuffer), _("%s does not have Living Quarters, employees got unhired!"), destination->name);
  417. MSO_CheckAddNewMessage(NT_TRANSFER_LOST, _("Transport mission"), cp_messageBuffer, qfalse, MSG_TRANSFERFINISHED, NULL);
  418. }
  419. - for (i = 0; i < MAX_EMPL; i++) {
  420. + for (i = EMPL_SOLDIER; i < MAX_EMPL; i++) {
  421. employee_t *employee = NULL;
  422. - while ((employee = (employee_t*) LIST_GetNext(transfer->employees[i], (void*) employee))) {
  423. + while ((employee = TR_GetNextEmployee(transfer, i, employee)) != NULL) {
  424. employee->baseHired = transfer->srcBase; /* Restore back the original baseid. */
  425. employee->transfer = qfalse;
  426. E_UnhireEmployee(employee);
  427. }
  428. }
  429. } else {
  430. - int i;
  431. - for (i = 0; i < MAX_EMPL; i++) {
  432. + employeeType_t i;
  433. + for (i = EMPL_SOLDIER; i < MAX_EMPL; i++) {
  434. employee_t *employee = NULL;
  435. - while ((employee = (employee_t*) LIST_GetNext(transfer->employees[i], (void*) employee))) {
  436. + while ((employee = TR_GetNextEmployee(transfer, i, employee)) != NULL) {
  437. employee->baseHired = transfer->srcBase; /* Restore back the original baseid. */
  438. employee->transfer = qfalse;
  439. E_UnhireEmployee(employee);
  440. @@ -152,7 +183,7 @@ static void TR_EmptyTransferCargo (base_t *destination, transfer_t *transfer, qb
  441. if (transfer->hasAircraft && success && transfer->srcBase) { /* Aircraft. Cannot come from mission */
  442. aircraft_t *aircraft = NULL;
  443.  
  444. - while ((aircraft = (aircraft_t*)LIST_GetNext(transfer->aircraft, (void*)aircraft))) {
  445. + while ((aircraft = TR_GetNextAircraft(transfer, aircraft)) != NULL) {
  446. if (AIR_CalculateHangarStorage(aircraft->tpl, destination, 0) > 0) {
  447. /* Move aircraft */
  448. AIR_MoveAircraftIntoNewHomebase(aircraft, destination);
  449. @@ -362,7 +393,7 @@ transfer_t* TR_TransferStart (base_t *srcBase, transferData_t *transData)
  450. employee_t *employee = NULL;
  451.  
  452. LIST_Delete(&transfer->employees[i]);
  453. - while ((employee = (employee_t*) LIST_GetNext(transData->trEmployeesTmp[i], (void*) employee))) {
  454. + while ((employee = (employee_t*) LIST_GetNext(transData->trEmployeesTmp[i], (void*) employee)) != NULL) {
  455. assert(E_IsInBase(employee, srcBase));
  456.  
  457. transfer->hasEmployees = qtrue;
  458. @@ -383,7 +414,7 @@ transfer_t* TR_TransferStart (base_t *srcBase, transferData_t *transData)
  459. }
  460. }
  461. LIST_Delete(&transfer->aircraft);
  462. - while ((aircraft = (aircraft_t*)LIST_GetNext(transData->aircraft, (void *)aircraft))) {
  463. + while ((aircraft = (aircraft_t*)LIST_GetNext(transData->aircraft, (void *)aircraft)) != NULL) {
  464. aircraft->status = AIR_TRANSFER;
  465. AIR_RemoveEmployees(aircraft);
  466. transfer->hasAircraft = qtrue;
  467. @@ -408,7 +439,7 @@ void TR_NotifyAircraftRemoved (const aircraft_t *aircraft)
  468.  
  469. if (!aircraft)
  470. return;
  471. - while ((transfer = TR_GetNext(transfer))) {
  472. + while ((transfer = TR_GetNext(transfer)) != NULL) {
  473. if (!transfer->active)
  474. continue;
  475. if (!transfer->hasAircraft)
  476. @@ -425,7 +456,7 @@ void TR_NotifyAircraftRemoved (const aircraft_t *aircraft)
  477. void TR_TransferRun (void)
  478. {
  479. transfer_t *transfer = NULL;
  480. - while ((transfer = TR_GetNext(transfer))) {
  481. + while ((transfer = TR_GetNext(transfer)) != NULL) {
  482. if (!transfer->active)
  483. continue;
  484. if (transfer->event.day == ccs.date.day && ccs.date.sec >= transfer->event.sec) {
  485. @@ -460,7 +491,7 @@ static void TR_ListTransfers_f (void)
  486. if (!ccs.numTransfers)
  487. Com_Printf("No active transfers.\n");
  488.  
  489. - for (; (transfer = TR_GetNext(transfer)); i++) {
  490. + for (; (transfer = TR_GetNext(transfer)) != NULL; i++) {
  491. dateLong_t date;
  492.  
  493. if (transIdx >= 0 && i != transIdx)
  494. @@ -491,12 +522,13 @@ static void TR_ListTransfers_f (void)
  495. }
  496. /* Carried Employees */
  497. if (transfer->hasEmployees) {
  498. - int j;
  499. + employeeType_t emplType;
  500. +
  501. Com_Printf("...Carried Employee:\n");
  502. - for (j = 0; j < MAX_EMPL; j++) {
  503. + for (emplType = EMPL_SOLDIER; emplType < MAX_EMPL; emplType++) {
  504. employee_t *employee = NULL;
  505.  
  506. - while ((employee = (employee_t*) LIST_GetNext(transfer->employees[i], (void*) employee))) {
  507. + while ((employee = TR_GetNextEmployee(transfer, emplType, employee)) != NULL) {
  508. if (employee->ugv) {
  509. /** @todo: improve ugv listing when they're implemented */
  510. Com_Printf("......ugv: %s [idx: %i]\n", employee->ugv->id, employee->idx);
  511. @@ -527,7 +559,7 @@ static void TR_ListTransfers_f (void)
  512. aircraft_t *aircraft = NULL;
  513.  
  514. Com_Printf("...Transfered Aircraft:\n");
  515. - while ((aircraft = (aircraft_t*)LIST_GetNext(transfer->aircraft, (void*)aircraft))) {
  516. + while ((aircraft = TR_GetNextAircraft(transfer, aircraft)) != NULL) {
  517. Com_Printf("......%s [idx: %i]\n", (aircraft) ? aircraft->id : "(null)", aircraft->idx);
  518. }
  519. }
  520. @@ -546,7 +578,7 @@ qboolean TR_SaveXML (mxml_node_t *p)
  521. transfer_t *transfer = NULL;
  522. mxml_node_t *n = mxml_AddNode(p, SAVE_TRANSFER_TRANSFERS);
  523.  
  524. - while ((transfer = TR_GetNext(transfer))) {
  525. + while ((transfer = TR_GetNext(transfer)) != NULL) {
  526. int j;
  527. mxml_node_t *s;
  528.  
  529. @@ -596,7 +628,7 @@ qboolean TR_SaveXML (mxml_node_t *p)
  530. for (j = 0; j < MAX_EMPL; j++) {
  531. employee_t *employee = NULL;
  532.  
  533. - while ((employee = (employee_t*) LIST_GetNext(transfer->employees[j], (void*) employee))) {
  534. + while ((employee = TR_GetNextEmployee(transfer, j, employee)) != NULL) {
  535. mxml_node_t *ss = mxml_AddNode(s, SAVE_TRANSFER_EMPLOYEE);
  536. mxml_AddInt(ss, SAVE_TRANSFER_UCN, employee->chr.ucn);
  537. }
  538. @@ -606,7 +638,7 @@ qboolean TR_SaveXML (mxml_node_t *p)
  539. if (transfer->hasAircraft) {
  540. aircraft_t *aircraft = NULL;
  541.  
  542. - while ((aircraft = (aircraft_t*)LIST_GetNext(transfer->aircraft, (void*)aircraft))) {
  543. + while ((aircraft = TR_GetNextAircraft(transfer, aircraft)) != NULL) {
  544. mxml_node_t *ss = mxml_AddNode(s, SAVE_TRANSFER_AIRCRAFT);
  545. mxml_AddInt(ss, SAVE_TRANSFER_ID, aircraft->idx);
  546. }
  547. diff --git a/src/client/campaign/cp_transfer.h b/src/client/campaign/cp_transfer.h
  548. index a186df8..fe8b69f 100644
  549. --- a/src/client/campaign/cp_transfer.h
  550. +++ b/src/client/campaign/cp_transfer.h
  551. @@ -132,5 +132,7 @@ transfer_t* TR_TransferStart(base_t *srcBase, transferData_t *transData);
  552. void TR_TransferAlienAfterMissionStart(const base_t *base, aircraft_t *transferAircraft);
  553.  
  554. transfer_t* TR_GetNext(transfer_t *lastTransfer);
  555. +employee_t* TR_GetNextEmployee(transfer_t *transfer, employeeType_t type, employee_t *lastEmployee);
  556. +aircraft_t* TR_GetNextAircraft(transfer_t *transfer, aircraft_t *lastAircraft);
  557.  
  558. #endif /* CLIENT_CL_TRANSFER_H */
  559. diff --git a/src/client/campaign/save/save_employee.h b/src/client/campaign/save/save_employee.h
  560. index 738fd9c..935a775 100644
  561. --- a/src/client/campaign/save/save_employee.h
  562. +++ b/src/client/campaign/save/save_employee.h
  563. @@ -70,5 +70,5 @@ DTD:
  564. >
  565.  
  566. ** for <character> check save_character.h
  567. -
  568. */
  569. +
  570. diff --git a/src/client/campaign/save/save_statistics.h b/src/client/campaign/save/save_statistics.h
  571. index d6b7bec..90e8724 100644
  572. --- a/src/client/campaign/save/save_statistics.h
  573. +++ b/src/client/campaign/save/save_statistics.h
  574. @@ -79,9 +79,9 @@ DTD:
  575.  
  576. <!ELEMENT employeeHad EMPTY>
  577. <!ATTLIST employeeHad
  578. - employeeType (soldier, scientist,
  579. - worker, robot, pilot) #REQUIRED
  580. + employeeType (soldier|scientist|
  581. + worker|robot|pilot) #REQUIRED
  582. employeeCount CDATA '0'
  583. >
  584. -
  585. */
  586. +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement