/* =========================================================================== Copyright (C) 2008 Poul Sander This file is part of Open Arena source code. Open Arena source code 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. Open Arena source code 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 Open Arena source code; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ //#include "cg_local.h" #include "../qcommon/q_shared.h" #include "../renderer/tr_types.h" #include "../game/bg_public.h" #include "../game/challenges.h" #ifdef PARTofUI #include "../q3_ui/ui_local.h" #else #include "../cgame/cg_local.h" #endif #define FILENAME "challenges.dat" //First two static variables that may only be accessed throgh functions in this file //The challengeTable is of constant size so there is room for more challenges being added in the furture static unsigned int challengeTable[CHALLENGES_MAX]; //We have a variable to see if the system is initialized static qboolean challengesInitialized = qfalse; //This function initializes the challenge system. It has no effect if the system is already intialized. void challenges_init(void) { fileHandle_t file; int fileLen; int i; //If already initialized then do nothing if(challengesInitialized) return; //Else open file fileLen = trap_FS_FOpenFile(FILENAME, &file, FS_READ); //If the file not is big enough to contain all challenges then initialize from zero if(fileLen=CHALLENGES_MAX) return 0; return challengeTable[challenge]; } void addChallenge(int challenge) { if(challenge>=CHALLENGES_MAX) { #ifndef PARTofUI CG_Printf("Challenge #%u is >=CHALLENGES_MAX\n",challenge); #endif return; //Maybe also print an error? } challenges_init(); challengeTable[challenge]++; //CG_Printf("Increased challenge #%u by one. Is now %u\n",challenge,challengeTable[challenge]); }