/************************************************************************** * * Othello II v2.53 - 08/02/2004 * * Copyright (C) 2000-2004 François LEIBER * * This file is part of Othello II. * * Othello II 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. * * Othello II 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 this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *************************************************************************/ unsigned char *Var = NULL; SYM_ENTRY *entry = NULL; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Charge la sauvegarde contenue dans 'oth2sav', ou crée cette variable si elle n'existe pas ou n'a pas le bon format ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void charger_sav() { char extension[] = "conf", signature[] = "OTH225"; entry = DerefSym(SymFindMain($(oth2sav))); if (entry != NULL) { Var = (unsigned char *)HLock(entry->handle); if (memcmp(Var + 2, signature, 6) != 0) { HeapUnlock(entry->handle); goto New; } memcpy(Sav, Var + 8, 61); JoueurType[BLANC] = *(Var + 69); JoueurType[NOIR] = *(Var + 70); Son = *(Var + 71); Tips = *(Var + 72); FaireTourner = *(Var + 73); Bib = *(Var + 74); } else { New: entry = DerefSym(SymAddMain($(oth2sav))); Var = (unsigned char *)HLock(entry->handle = HeapAlloc(82)); *(unsigned short *)Var = 80; strcpy(Var + 2, signature); *(Var + 75) = 0; strcpy(Var + 76, extension); *(Var + 81) = OTH_TAG; } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Sauvegarde la partie et la configuration dans 'oth2sav' ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void sauver_sav() { Sav[NbrePions - 4] = 0; memcpy(Var + 8, Sav, 61); *(Var + 69) = JoueurType[BLANC]; *(Var + 70) = JoueurType[NOIR]; *(Var + 71) = Son; *(Var + 72) = Tips; *(Var + 73) = FaireTourner; *(Var + 74) = Bib; entry->flags.bits.hidden = 1; HeapUnlock(entry->handle); }