/* * Seven Kingdoms: Ancient Adversaries * * Copyright 1997,1998 Enlight Software Ltd. * * 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, see . * */ //Filename : OMP_CRC.CPP //Description : crc checking for multiplayer debugging //Owner : Alex #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // ###### patch begin Gilbert 20/1 #######// #include #include // ###### patch end Gilbert 20/1 #######// #include // ###### patch begin Gilbert 21/1 #####// #define RTRIM_ARRAY(a,s) { if(sslot_count; RTRIM_ARRAY(slot_object_id_array, layoutCount); RTRIM_ARRAY(train_queue_skill_array, train_queue_count); RTRIM_ARRAY(train_queue_race_array, train_queue_count); RTRIM_ARRAY(linked_firm_array, linked_firm_count); RTRIM_ARRAY(linked_firm_enable_array, linked_firm_count); RTRIM_ARRAY(linked_town_array, linked_town_count); RTRIM_ARRAY(linked_town_enable_array, linked_town_count); } //----------- End of function Town::clear_ptr -----------// //----------- End of function NationBase::crc8 -----------// UCHAR NationBase::crc8() { NationBase &dummyNationBase = *(NationBase *)temp_obj.nation; memcpy(&dummyNationBase, this, sizeof(NationBase)); dummyNationBase.clear_ptr(); *((char**) &dummyNationBase) = NULL; UCHAR c = ::crc8((UCHAR*)&dummyNationBase, sizeof(NationBase)); return c; } //----------- End of function NationBase::crc8 -----------// //----------- End of function NationBase::clear_ptr -----------// void NationBase::clear_ptr() { nation_type = 0; memset(nation_name_str, 0, sizeof(nation_name_str) ); // garbage may exist after the '\0' next_frame_ready = 0; is_allied_with_player = 0; // ignore contact_msg_flag in relation_array for(short nationRecno=1; nationRecno <= MAX_NATION; ++nationRecno) { get_relation(nationRecno)->contact_msg_flag = 0; } } //----------- End of function NationBase::clear_ptr -----------// //----------- End of function Bullet::crc8 -----------// UCHAR Bullet::crc8() { Bullet &dummyBullet = *(Bullet *)temp_obj.bullet; memcpy(&dummyBullet, this, sizeof(Bullet)); dummyBullet.clear_ptr(); *((char**) &dummyBullet) = NULL; UCHAR c = ::crc8((UCHAR*)&dummyBullet, sizeof(Bullet)); return c; } //----------- End of function Bullet::crc8 -----------// //----------- End of function Bullet::clear_ptr -----------// void Bullet::clear_ptr() { Sprite::clear_ptr(); } //----------- End of function Bullet::clear_ptr -----------// //----------- End of function Projectile::crc8 -----------// UCHAR Projectile::crc8() { Projectile &dummyProjectile = *(Projectile *)temp_obj.projectile; memcpy(&dummyProjectile, this, sizeof(Projectile)); dummyProjectile.clear_ptr(); *((char**) &dummyProjectile) = NULL; UCHAR c = ::crc8((UCHAR*)&dummyProjectile, sizeof(Projectile)); return c; } //----------- End of function Projectile::crc8 -----------// //----------- End of function Projectile::clear_ptr -----------// void Projectile::clear_ptr() { memset(&act_bullet, 0, sizeof(act_bullet)); memset(&bullet_shadow, 0, sizeof(bullet_shadow)); Bullet::clear_ptr(); } //----------- End of function Projectile::clear_ptr -----------// //----------- End of function BulletHoming::crc8 -----------// UCHAR BulletHoming::crc8() { BulletHoming &dummyBulletHoming = *(BulletHoming *)temp_obj.bullet_homing; memcpy(&dummyBulletHoming, this, sizeof(BulletHoming)); dummyBulletHoming.clear_ptr(); *((char**) &dummyBulletHoming) = NULL; UCHAR c = ::crc8((UCHAR*)&dummyBulletHoming, sizeof(BulletHoming)); return c; } //----------- End of function BulletHoming::crc8 -----------// //----------- End of function BulletHoming::clear_ptr -----------// void BulletHoming::clear_ptr() { Bullet::clear_ptr(); } //----------- End of function BulletHoming::clear_ptr -----------// //----------- End of function BulletFlame::crc8 -----------// UCHAR BulletFlame::crc8() { BulletFlame &dummyBulletFlame = *(BulletFlame *)temp_obj.bullet_flame; memcpy(&dummyBulletFlame, this, sizeof(BulletFlame)); dummyBulletFlame.clear_ptr(); *((char**) &dummyBulletFlame) = NULL; UCHAR c = ::crc8((UCHAR*)&dummyBulletFlame, sizeof(BulletFlame)); return c; } //----------- End of function BulletFlame::crc8 -----------// //----------- Begin of function BulletFlame::clear_ptr -----------// void BulletFlame::clear_ptr() { Bullet::clear_ptr(); } //----------- End of function BulletFlame::clear_ptr -----------// // ###### patch begin Gilbert 20/1 #######// //----------- Begin of function Rebel::crc8 -----------// UCHAR Rebel::crc8() { Rebel &dummyRebel = *(Rebel *)temp_obj.rebel; memcpy(&dummyRebel, this, sizeof(Rebel)); dummyRebel.clear_ptr(); UCHAR c = ::crc8((UCHAR *)&dummyRebel, sizeof(Rebel)); return c; } //----------- End of function Rebel::crc8 -----------// //----------- Begin of function Rebel::clear_ptr -----------// void Rebel::clear_ptr() { } //----------- End of function Rebel::clear_ptr -----------// //----------- Begin of function Spy::crc8 -----------// UCHAR Spy::crc8() { Spy &dummySpy = *(Spy *)temp_obj.spy; memcpy(&dummySpy, this, sizeof(Spy)); dummySpy.clear_ptr(); UCHAR c = ::crc8((UCHAR *)&dummySpy, sizeof(Spy)); return c; } //----------- End of function Spy::crc8 -----------// //----------- Begin of function Spy::clear_ptr -----------// void Spy::clear_ptr() { } //----------- End of function Spy::clear_ptr -----------// // ###### patch end Gilbert 20/1 #######// //----------- Begin of function TalkMsg::crc8 -----------// UCHAR TalkMsg::crc8() { TalkMsg &dummyTalkMsg = *(TalkMsg *)temp_obj.talk_msg; memcpy(&dummyTalkMsg, this, sizeof(TalkMsg)); dummyTalkMsg.clear_ptr(); // *((char**) &dummyTalkMsg) = NULL; UCHAR c = ::crc8((UCHAR*)&dummyTalkMsg, sizeof(TalkMsg)); return c; } //----------- End of function TalkMsg::crc8 -----------// //----------- Begin of function TalkMsg::clear_ptr -----------// void TalkMsg::clear_ptr() { } //----------- End of function TalkMsg::clear_ptr -----------//