All pastes #605919 Raw Edit

Anonymous

public c v1 · immutable
·published 2007-07-06 15:12 UTC
rendered paste body
Index: src/client/cl_ufo.c===================================================================--- src/client/cl_ufo.c	(Revision 9513)+++ src/client/cl_ufo.c	(Arbeitskopie)@@ -378,6 +378,7 @@ 			od = &csi.ods[item]; 			assert(od); 			/* Process UFO recovery. */+			/* FIXME: call B_UpdateStorageAndCapacity here, too? */ 			base->storage.num[item]++;	/* Add dummy UFO item to enable research topic. */ 			RS_MarkCollected(od->tech);	/* Enable research topic. */ 			/* Reset this recovery. */Index: src/client/cl_inventory.c===================================================================--- src/client/cl_inventory.c	(Revision 9513)+++ src/client/cl_inventory.c	(Arbeitskopie)@@ -286,9 +286,7 @@ 			Sys_Error("INV_SellOrAddItems: No tech for %s / %s\n", csi.ods[cargo[i].idx].id, csi.ods[cargo[i].idx].name); 		/* If the related technology is NOT researched, don't sell items. */ 		if (!RS_IsResearched_ptr(tech)) {-			base->storage.num[cargo[i].idx] += cargo[i].amount;-			/* Items not researched cannot be thrown out even if not enough space in storage. */-			base->capacities[CAP_ITEMS].cur += (cargo[i].amount * csi.ods[cargo[i].idx].size);+			B_UpdateStorageAndCapacity(base, cargo[i].idx, cargo[i].amount, qfalse); 			if (cargo[i].amount > 0) 				RS_MarkCollected(tech); 			continue;@@ -305,8 +303,7 @@ 				for (j = 0; j < cargo[i].amount; j++) { 					if (base->capacities[CAP_ITEMS].max - base->capacities[CAP_ITEMS].cur >= csi.ods[cargo[i].idx].size) { 						/* There is a space, add to base storage and increase capacity. */-						base->storage.num[cargo[i].idx]++;-						base->capacities[CAP_ITEMS].cur += csi.ods[cargo[i].idx].size;+						B_UpdateStorageAndCapacity(base, cargo[i].idx, 1, qfalse); 					} else { 						/* Not enough space, sell item. */ 						notenoughspace = qtrue;@@ -397,7 +394,7 @@ 		base->storage = *ed; 	/* Initial soldiers and their equipment. */-	if (cl_start_employees->value) {+	if (cl_start_employees->integer) { 		Cbuf_AddText("assign_initial;"); 	} else { 		for (i = 0, ed = csi.eds; i < csi.numEDs; i++, ed++) {@@ -408,15 +405,14 @@ 			Com_DPrintf("B_BuildBase_f: Initial Phalanx equipment %s not found.\n", eqname); 		} else { 			for (i = 0; i < csi.numODs; i++)-				base->storage.num[i] += ed->num[i] / 5;+				B_UpdateStorageAndCapacity(base, i, ed->num[i] / 5, qfalse); 		} 	} 	/* Pay for the initial equipment as well as update storage capacity. */-	for (i = 0; i < csi.numODs; i++) {+	for (i = 0; i < csi.numODs; i++) 		price += base->storage.num[i] * csi.ods[i].price;-		base->capacities[CAP_ITEMS].cur += base->storage.num[i] * csi.ods[i].size;-	}+ 	/* Finally update credits. */ 	CL_UpdateCredits(ccs.credits - price); }@@ -545,6 +541,7 @@ 		size += compod->size * comp->item_amount[i]; 		/* Add to base storage only if this is real disassembling, not calculation of size. */ 		if (!calculate) {+			/* FIXME: call B_UpdateStorageAndCapacity(base, j, comp->item_amount[i], qfalse); */ 			base->storage.num[j] += comp->item_amount[i]; 			Com_DPrintf("INV_DisassemblyItem()... added %i amounts of %s\n", comp->item_amount[i], compod->id); 		}Index: src/client/cl_basemanagement.c===================================================================--- src/client/cl_basemanagement.c	(Revision 9513)+++ src/client/cl_basemanagement.c	(Arbeitskopie)@@ -3285,3 +3285,30 @@ 	return qtrue; }++/**+ * @brief Update the storage amount and the capacities for the storages in the base+ * @param[in] base The base which storage and capacity should be updated+ * @param[in] objIDX The idx in csi.ods+ * @param[in] amount Amount to be added to removed+ */+extern qboolean B_UpdateStorageAndCapacity (base_t* base, int objIDX, int amount, qboolean reset)+{+	assert(base);+	if (reset) {+		base->storage.num[objIDX] = 0;+		base->storage.num_loose[item] = 0; /* FIXME: needed? */+		base->capacities[CAP_ITEMS].cur = 0;+	} else {+		if (base->capacities[CAP_ITEMS].max - base->capacities[CAP_ITEMS].cur >= csi.ods[objIDX].size) {+			base->storage.num[objIDX] += amount;+			/* Items not researched cannot be thrown out even if not enough space in storage. */+			base->capacities[CAP_ITEMS].cur += (amount * csi.ods[objIDX].size);+		} else {+			Com_DPrintf("B_UpdateStorageAndCapacity: Not enough storage space (item: %i, amount: %i)\n", objIDX, amount);+			return qfalse;+		}+	}++	return qtrue;+}\ Kein Zeilenvorschub am Ende der DateiIndex: src/client/cl_basemanagement.h===================================================================--- src/client/cl_basemanagement.h	(Revision 9513)+++ src/client/cl_basemanagement.h	(Arbeitskopie)@@ -300,6 +300,7 @@ void B_BuildingDestroy(building_t* building, base_t* base); void CL_DropshipReturned(base_t* base, aircraft_t* aircraft);-void B_UpdateBaseCapacities (baseCapacities_t cap, base_t *base);+void B_UpdateBaseCapacities(baseCapacities_t cap, base_t *base);+qboolean B_UpdateStorageAndCapacity(base_t* base, int objIDX, int amount, qboolean reset); #endif /* CLIENT_CL_BASEMANGEMENT_H */Index: src/client/cl_aliencont.c===================================================================--- src/client/cl_aliencont.c	(Revision 9513)+++ src/client/cl_aliencont.c	(Arbeitskopie)@@ -224,16 +224,14 @@ 			if (Q_strncmp(tobase->alienscont[j].alientype, cargo[i].alientype, MAX_VAR) == 0) { 				tobase->alienscont[j].amount_dead += cargo[i].amount_dead; 				/* Add breathing apparatuses as well and update storage capacity. */-				tobase->storage.num[albridx] += cargo[i].amount_dead;-				tobase->capacities[CAP_ITEMS].cur += cargo[i].amount_dead * csi.ods[albridx].size;+				B_UpdateStorageAndCapacity(tobase, albridx, cargo[i].amount_dead, qfalse); 				if (cargo[i].amount_alive <= 0) 					continue; 				if (!alienBreathing) { 					/* we cannot store alive aliens without rs_alien_breathing tech */ 					tobase->alienscont[j].amount_dead += cargo[i].amount_alive; 					/* Add breathing apparatuses as well and update storage capacity. */-					tobase->storage.num[albridx] += cargo[i].amount_alive;-					tobase->capacities[CAP_ITEMS].cur += cargo[i].amount_alive * csi.ods[albridx].size;+					B_UpdateStorageAndCapacity(tobase, albridx, cargo[i].amount_alive, qfalse); 					/* only once */ 					if (!messageAlreadySet) { 						MN_AddNewMessage(_("Notice"), _("You cannot hold alive aliens yet. Aliens died."), qfalse, MSG_STANDARD, NULL);@@ -247,6 +245,7 @@ 						} else { 							if (!limit) { 								/* Limit is hit. Set the amount of currently stored in capacities. */+								/* FIXME: this is needed? */ 								tobase->capacities[CAP_ALIENS].cur = tobase->capacities[CAP_ALIENS].max; 								MN_AddNewMessage(_("Notice"), _("You don't have enough space in Alien Containment. Some aliens got killed."), qfalse, MSG_STANDARD, NULL); 								limit = qtrue;@@ -255,8 +254,7 @@ 								/* Just kill aliens which don't fit the limit. */ 								tobase->alienscont[j].amount_dead++; 								/* Add breathing apparatus as well and update storage capacity. */-								tobase->storage.num[albridx]++;-								tobase->capacities[CAP_ITEMS].cur += csi.ods[albridx].size;+								B_UpdateStorageAndCapacity(tobase, albridx, 1, qfalse); 							} 						} 					}Index: src/client/cl_campaign.c===================================================================--- src/client/cl_campaign.c	(Revision 9513)+++ src/client/cl_campaign.c	(Arbeitskopie)@@ -1049,10 +1049,9 @@ 	E_DeleteAllEmployees(base); 	/* Destroy all items in storage */-	for (item = 0; item < csi.numODs; item++) {-		base->storage.num[item] = 0;-		base->storage.num_loose[item] = 0;-	}+	for (item = 0; item < csi.numODs; item++)+		/* reset storage and capacity */+		B_UpdateStorageAndCapacity(base, item, 0, qtrue); 	/* Remove all aircrafts from the base. */ 	for (ac = base->numAircraftInBase-1; ac >= 0; ac--)@@ -2600,7 +2599,7 @@ 		tech = csi.ods[i].tech; 		if (!tech) 			Sys_Error("CL_DebugAllItems_f: No tech for %s / %s\n", csi.ods[i].id, csi.ods[i].name);-		base->storage.num[i]++;+		B_UpdateStorageAndCapacity(base, i, 1, qfalse); 		if (base->storage.num[i] > 0) 			RS_MarkCollected(tech); 	}