/* Packets checksum for One Must Fall: Battlegrounds 0.1 by Luigi Auriemma e-mail: aluigi@autistici.org web: aluigi.org This simple function calculates the checksum of a OMF packet and returns it as a 32bit number that you must copy at the end of the packet (the last 4 bytes of each packet). Remember to pass ALL the size of the packet (checksum included) because as you can see the last 4 bytes are automatically skipped into my function Copyright 2004,2005,2006 Luigi Auriemma 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. 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA http://www.gnu.org/licenses/gpl.txt */ unsigned int omfcksum(unsigned char *buff, int size) { unsigned char eax = 0, *ptr; unsigned int cksum = 0; size -= 4; ptr = (unsigned char *)&cksum; while(size--) { ptr[eax] += *buff; buff++; eax++; if(eax == 4) eax = 0; } return(cksum); }