/* This file is part of Warzone 2100. Copyright (C) 1999-2004 Eidos Interactive Copyright (C) 2005-2009 Warzone Resurrection Project Warzone 2100 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Warzone 2100 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Warzone 2100; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* * Mechanics.c * * Game world mechanics. * */ #include "lib/framework/frame.h" #include "mechanics.h" #include "stats.h" #include "structure.h" #include "game.h" #include "power.h" #include "projectile.h" #include "move.h" #include "message.h" #include "visibility.h" /* Shutdown the mechanics system */ bool mechanicsShutdown(void) { BASE_OBJECT *psObj, *psNext; for(psObj = psDestroyedObj; psObj != NULL; psObj = psNext) { psNext = psObj->psNext; switch (psObj->type) { case OBJ_DROID: droidRelease((DROID *)psObj); break; case OBJ_STRUCTURE: structureRelease((STRUCTURE *)psObj); break; case OBJ_FEATURE: featureRelease((FEATURE *)psObj); break; default: ASSERT(!"unknown object type", "unknown object type in destroyed object list"); } free(psObj); } psDestroyedObj = NULL; return true; } // Allocate the list for a component BOOL allocComponentList(COMPONENT_TYPE type, SDWORD number) { SDWORD inc, comp; //allocate the space for the Players' component lists for (inc=0; inc < MAX_PLAYERS; inc++) { apCompLists[inc][type] = (UBYTE *) malloc(sizeof(UBYTE) * number); if (apCompLists[inc][type] == NULL) { debug( LOG_FATAL, "Out of memory assigning Player Component Lists" ); abort(); return false; } //initialise the players' lists for (comp=0; comp