diff --git a/inc/common/crc.h b/inc/common/crc.h new file mode 100644 index 000000000..453796277 --- /dev/null +++ b/inc/common/crc.h @@ -0,0 +1,25 @@ +/* +Copyright (C) 1997-2001 Id Software, Inc. + +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., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#pragma once + +uint16_t CRC_Block(const byte *start, size_t count); + +#if USE_CLIENT +byte COM_BlockSequenceCRCByte(const byte *base, size_t length, int sequence); +#endif diff --git a/meson.build b/meson.build index 1b0668e8f..2d9a126ab 100644 --- a/meson.build +++ b/meson.build @@ -14,6 +14,7 @@ common_src = [ 'src/common/cmd.c', 'src/common/cmodel.c', 'src/common/common.c', + 'src/common/crc.c', 'src/common/cvar.c', 'src/common/error.c', 'src/common/field.c', @@ -124,7 +125,6 @@ client_src = [ 'src/client/cgame.c', 'src/client/cgame_classic.c', 'src/client/console.c', - 'src/client/crc.c', 'src/client/demo.c', 'src/client/download.c', 'src/client/effects.c', diff --git a/src/client/client.h b/src/client/client.h index 972e79c7b..b7682dc3a 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -1326,11 +1326,6 @@ void CL_GTV_Shutdown(void); #define CL_GTV_Shutdown() (void)0 #endif -// -// crc.c -// -byte COM_BlockSequenceCRCByte(const byte *base, size_t length, int sequence); - // // cgame.c // diff --git a/src/client/input.c b/src/client/input.c index f0afea2ec..237e37ea3 100644 --- a/src/client/input.c +++ b/src/client/input.c @@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., // cl.input.c -- builds an intended movement command to send to the server #include "client.h" +#include "common/crc.h" static cvar_t *cl_nodelta; static cvar_t *cl_maxpackets; diff --git a/src/client/crc.c b/src/common/crc.c similarity index 98% rename from src/client/crc.c rename to src/common/crc.c index b661f0a08..68aec0c27 100644 --- a/src/client/crc.c +++ b/src/common/crc.c @@ -17,7 +17,8 @@ with this program; if not, write to the Free Software Foundation, Inc., */ /* crc.c */ -#include "client.h" +#include "shared/shared.h" +#include "common/crc.h" // this is a 16 bit, non-reflected CRC using the polynomial 0x1021 // and the initial and final xor values shown below... in other words, the @@ -61,7 +62,7 @@ static const uint16_t crctable[256] = { 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 }; -static uint16_t CRC_Block(const byte *start, size_t count) +uint16_t CRC_Block(const byte *start, size_t count) { uint16_t crc = CRC_INIT_VALUE; @@ -71,6 +72,8 @@ static uint16_t CRC_Block(const byte *start, size_t count) return crc; } +#if USE_CLIENT + static const byte chktbl[1024] = { 0x84, 0x47, 0x51, 0xc1, 0x93, 0x22, 0x21, 0x24, 0x2f, 0x66, 0x60, 0x4d, 0xb0, 0x7c, 0xda, 0x88, 0x54, 0x15, 0x2b, 0xc6, 0x6c, 0x89, 0xc5, 0x9d, 0x48, 0xee, 0xe6, 0x8a, 0xb5, 0xf4, @@ -178,3 +181,5 @@ byte COM_BlockSequenceCRCByte(const byte *base, size_t length, int sequence) return crc; } + +#endif // USE_CLIENT