--- deliantra/server/include/living.h 2007/05/12 18:14:47 1.13 +++ deliantra/server/include/living.h 2007/05/28 21:15:56 1.15 @@ -1,30 +1,32 @@ /* - * CrossFire, A Multiplayer game + * This file is part of Crossfire TRT, the Multiplayer Online Role Playing Game. * - * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team - * Copyright (C) 2002 Mark Wedel & Crossfire Development Team - * Copyright (C) 1992 Frank Tore Johansen + * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team + * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team + * Copyright (©) 1992,2007 Frank Tore Johansen * - * This program 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. + * Crossfire TRT 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. * - * This program 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. + * This program 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. - * - * The authors can be reached via e-mail at crossfire@schmorp.de + * You should have received a copy of the GNU General Public License along + * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * The authors can be reached via e-mail to */ #ifndef LIVING_H #define LIVING_H +#include + // corresponds to some arrays in common/living.C enum { STR, @@ -83,8 +85,31 @@ sint16 ACC (RW, grace); /* Grace. Used to invoke clerical prayers. */ sint16 ACC (RW, maxgrace); /* Grace. Used to invoke clerical prayers. */ - sint8 &stat (int index); - sint8 stat (int index) const; + // this method enforces field ordering and should not normally result in + // any code being generated strictly speaking, c++ compilers may reorder + // stat fields, so check for it and declare those compilers unsupported. + void check_ordering () const + { + assert ((sint8 *)&Str - (sint8 *)&Str == STR); + assert ((sint8 *)&Dex - (sint8 *)&Str == DEX); + assert ((sint8 *)&Con - (sint8 *)&Str == CON); + assert ((sint8 *)&Int - (sint8 *)&Str == INT); + assert ((sint8 *)&Wis - (sint8 *)&Str == WIS); + assert ((sint8 *)&Pow - (sint8 *)&Str == POW); + assert ((sint8 *)&Cha - (sint8 *)&Str == CHA); + } + + sint8 &stat (int index) + { + check_ordering (); + return ((sint8 *)&Str)[index]; + } + + sint8 stat (int index) const + { + check_ordering (); + return ((const sint8 *)&Str)[index]; + } }; #endif