From 585a3804c43874ad48f7c8998ea14fe214a3f61c Mon Sep 17 00:00:00 2001 From: "Azamat H. Hackimov" Date: Mon, 23 Sep 2024 01:53:33 +0300 Subject: [PATCH] Remove unused serial check code --- Descent3/CMakeLists.txt | 2 - Descent3/TelCom.cpp | 49 -------- Descent3/d3serial.cpp | 227 -------------------------------------- Descent3/d3serial.h | 82 -------------- Descent3/multi_client.cpp | 6 +- editor/CMakeLists.txt | 2 - 6 files changed, 2 insertions(+), 366 deletions(-) delete mode 100644 Descent3/d3serial.cpp delete mode 100644 Descent3/d3serial.h diff --git a/Descent3/CMakeLists.txt b/Descent3/CMakeLists.txt index 7ae9570d..8cdd2755 100644 --- a/Descent3/CMakeLists.txt +++ b/Descent3/CMakeLists.txt @@ -43,7 +43,6 @@ set(HEADERS ctlconfigtxt.h d3movie.h d3music.h - d3serial.h damage.h damage_external.h deathinfo_external.h @@ -169,7 +168,6 @@ set(CPPS D3ForceFeedback.cpp d3movie.cpp d3music.cpp - d3serial.cpp damage.cpp debuggraph.cpp dedicated_server.cpp diff --git a/Descent3/TelCom.cpp b/Descent3/TelCom.cpp index f493cccb..554f2f63 100644 --- a/Descent3/TelCom.cpp +++ b/Descent3/TelCom.cpp @@ -3214,55 +3214,6 @@ void TelcomEndScreen(void) { float myrand(float max) { return (max * (((float)ps_rand()) / ((float)D3_RAND_MAX))); } -///////////////////////////////////////////////////////////////////////////// -// These are the functions used for serialization, yes they are out of place, -// But that is to keep them away from other parts of the code that has -// the rest of the serialization. These probably can be moved to some other -// file....if this function returns: -// 1 : than it's a serialized exe, num will be given the serial num -// 0 : than it isn't a serialized exe -// -1 : detected a hacked exe -#define INTERNAL_SERIALNUM_TAG "XFCABBFFAX" -char GetInternalSerializationNumber(int *num) { - static char mydata[] = INTERNAL_SERIALNUM_TAG; - - // first check to see if the value is the same (non-serialized EXE) - if (mydata[0] == 'X' && ((mydata[9] + 2) == 'Z')) { - int value = 0; - char c; - for (int i = 0; i < 8; i++) { - c = mydata[i + 1]; - if (c >= 'A' && c <= 'F') { - value = value * 16 + (c - 'A' + 10); - } else - goto get_num; - } - - if (value == 0xFCABBFFA) - return 0; - } - -get_num: - // we got to get the serial num if we can - int value = 0; - char c; - for (int i = 0; i < 8; i++) { - c = mydata[i + 1]; - if (c >= '0' && c <= '9') { - value = value * 16 + c - '0'; - } else if (c >= 'A' && c <= 'F') { - value = value * 16 + c - 'A' + 10; - } else - return -1; - } - - // now byte swap the value to get it to it's original value - value = (((value & 0xFF000000) >> 24) | ((value & 0xFF0000) >> 8) | ((value & 0xFF) << 24) | ((value & 0xFF00) << 8)); - - *num = value; - return 1; -} - /* **************************************************************** * TelCom Sound Functions * diff --git a/Descent3/d3serial.cpp b/Descent3/d3serial.cpp deleted file mode 100644 index 257d9a96..00000000 --- a/Descent3/d3serial.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/* -* Descent 3 -* Copyright (C) 2024 Parallax Software -* -* 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 3 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 . - ---- HISTORICAL COMMENTS FOLLOW --- - - * $Logfile: /DescentIII/main/d3serial.cpp $ - * $Revision: 15 $ - * $Date: 5/13/99 11:18a $ - * $Author: Matt $ - * - * Functions to check the copy of the executable for expiration, registered name - * - * $Log: /DescentIII/main/d3serial.cpp $ - * - * 15 5/13/99 11:18a Matt - * Added some text. - * - * 14 4/16/99 11:59a Matt - * Took out include of io.h, because it wasn't needed. - * - * 13 4/16/99 12:39a Matt - * Took out Linux ifdef around include of io.h, since it's a system header - * file and there's no harm in including it in the Windows version. - * - * 12 4/15/99 1:38a Jeff - * changes for linux compile - * - * 11 4/14/99 2:50a Jeff - * fixed some case mismatched #includes - * - * 10 2/17/99 3:06p Matt - * Updated copyrights. - * - * 9 10/18/98 9:12p Matt - * Use new symbolic constant for the program name. - * - * 8 10/13/98 2:30p Jeff - * changed serialization msg for demo - * - * 7 10/11/98 2:58a Jeff - * fixed serialization code - * - * 6 7/13/98 12:41p Jeff - * added serial number support - * - * 5 6/08/98 3:16p Matt - * Mucked with formatting & content of serialization message. - * - * 4 6/04/98 11:32a Jeff - * Better 'warning' box for the serialization - * - * 3 2/10/98 10:43a Jeff - * fixed it so a nonregistered version will run (to make development - * easier) - * - * 2 2/07/98 6:33p Jeff - * Initial Creation (Based on D2 serialization) - * - * $NoKeywords: $ - */ - -#include -#include -#include - -#include "d3serial.h" -#include "game.h" -#include "debug.h" -#include "descent.h" -#include -#include "mono.h" -#include "cfile.h" -#include "program.h" - -#include - -#define SERIAL_NO_ERR 0 -#define SERIAL_EXPIRED 1 -#define SERIAL_BAD_CHECKSUM 2 -#define SERIAL_UNREGISTERED 3 - -static char name_copy[DESC_ID_LEN]; - -static uint32_t d3_serialnum = 100000; - -// checks the exectuable (serialization) -int SerialCheck(void) { - char name2[] = DESC_ID_TAG "0000000000000000000000000000000000000000"; - char time_str[] = DESC_DEAD_TIME_TAG "00000000"; - int i, found; - uint32_t *checksum, test_checksum; - uint32_t *serialnum; - time_t current_time, saved_time; - -#ifdef DEMO - char regstr[] = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NOTICE " - "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" - "\nThis Descent 3 Demo %s has been specially prepared for\n" - "\n" - "\t\t%s (Serial Num: %d)\n" - "\n" - " and is the Confidential Property of Outrage Entertainment, Inc.\n" - "\n" - "\n" - "\t\tDISTRIBUTION IS PROHIBITED\n" - "\n" - "\n" - " Descent 3 is Copyright (c) 1998,1999 Outrage Entertainment, Inc.\n" - "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"; -#else - char regstr[] = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NOTICE " - "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" - "\nThis pre-release version of Descent 3 has been specially prepared for\n" - "\n" - "\t\t%s (Serial Num: %d)\n" - "\n" - " and is the Confidential Property of Outrage Entertainment, Inc.\n" - "\n" - "\n" - "\t\tDISTRIBUTION IS PROHIBITED\n" - "\n" - "This version of Descent 3 should be used for evaluation and testing only.\n" - "Because the game is not yet complete, items may be missing the bugs may be\n" - "encountered.\n" - "\n" - " Descent 3 is Copyright (c) 1998,1999 Outrage Entertainment, Inc.\n" - "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"; -#endif - - // get the expiration time of the executable - char *start_time = &time_str[DESC_DEAD_TIME_TAG_LEN]; - saved_time = (time_t)strtol(start_time, NULL, 16); - if (saved_time == (time_t)0) - // this guy has never been registered with the serialization program - return SERIAL_NO_ERR; - - // adjust pointer, so it points to the registered name - char *name = name2 + DESC_ID_TAG_LEN; - - // save for later use - strcpy(name_copy, name); - - // get current date from the system - current_time = time(NULL); - - // check to see if executable has expired - if (current_time >= saved_time) { - return SERIAL_EXPIRED; - } - - // check the checksum created by the registered name - test_checksum = 0; - for (i = 0; i < (signed)strlen(name); i++) { - found = 0; - test_checksum += name[i]; - if (((test_checksum / 2) * 2) != test_checksum) - found = 1; - test_checksum = test_checksum >> 1; - if (found) - test_checksum |= 0x80000000; - } - static char desc_id_checksum_str[] = DESC_CHKSUM_TAG "0000"; // 4-byte checksum - char *checksum_ptr = desc_id_checksum_str + DESC_CHKSUM_TAG_LEN; - - // compare generated checksum with that in the executable - checksum = (uint32_t *)&(checksum_ptr[0]); - if (test_checksum != *checksum) { - return SERIAL_BAD_CHECKSUM; - } - - static char desc_id_serialnum_str[] = DESC_SERIALNUM_TAG "0000"; // 4-byte serialnum - char *serialnum_ptr = desc_id_serialnum_str + DESC_SERIALNUM_TAG_LEN; - - serialnum = (uint32_t *)&(serialnum_ptr[0]); - d3_serialnum = *serialnum; - - // this guy is ok, we can exit clean now - char buffer[400]; - -#ifdef DEMO - char ver[10]; - snprintf(ver, sizeof(ver), "Beta %d.%d.%d", D3_MAJORVER, D3_MINORVER, D3_BUILD); - snprintf(buffer, sizeof(buffer), regstr, ver, name, d3_serialnum); -#else - snprintf(buffer, sizeof(buffer), regstr, name, d3_serialnum); -#endif - - Debug_MessageBox(OSMBOX_OK, PRODUCT_NAME, buffer); - - return SERIAL_NO_ERR; -} - -// displays an error box displaying what went wrong with serialization checking -void SerialError(int error) { - switch (error) { - case SERIAL_EXPIRED: { - Debug_MessageBox(OSMBOX_OK, PRODUCT_NAME, "Executable has expired"); - break; - } - case SERIAL_BAD_CHECKSUM: { - Debug_MessageBox(OSMBOX_OK, PRODUCT_NAME, "Bad Checksum"); - break; - } - case SERIAL_UNREGISTERED: { - Debug_MessageBox(OSMBOX_OK, PRODUCT_NAME, "This is unregistered, please serialize"); - break; - } - } -} - -uint32_t SerialGetSerialNum(void) { return d3_serialnum; } diff --git a/Descent3/d3serial.h b/Descent3/d3serial.h deleted file mode 100644 index 530d336e..00000000 --- a/Descent3/d3serial.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -* Descent 3 -* Copyright (C) 2024 Parallax Software -* -* 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 3 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 . - ---- HISTORICAL COMMENTS FOLLOW --- - - * $Logfile: /DescentIII/main/d3serial.h $ - * $Revision: 5 $ - * $Date: 10/11/98 2:58a $ - * $Author: Jeff $ - * - * file header for serialization - * - * $Log: /DescentIII/main/d3serial.h $ - * - * 5 10/11/98 2:58a Jeff - * fixed serialization code - * - * 4 9/29/98 3:04p Jeff - * - * 3 7/13/98 12:41p Jeff - * added serial number support - * - * 2 2/07/98 6:35p Jeff - * - * $NoKeywords: $ - */ - -#ifndef __SERIALIZE_H_ -#define __SERIALIZE_H_ - -#include -#include - -#define DESC_ID_LEN 40 // how long the id string can be -#define DESC_CHECKSUM_LEN 4 // checksum is 4 bytes -#define DESC_SERIALNUM_LEN 4 // serialnum is 4 bytes -#define DESC_DEAD_TIME_LEN 8 // dead time is 8 bytes - -#define DESC_ID_TAG "Midway in our life's journey, I went astray" -#define DESC_ID_TAG_LEN 43 - -#define DESC_CHKSUM_TAG "alone in a dark wood." -#define DESC_CHKSUM_TAG_LEN 21 - -#define DESC_SERIALNUM_TAG "You've entered Lord Spam's Pleasure Dome" -#define DESC_SERIALNUM_TAG_LEN 40 - -#define DESC_DEAD_TIME_TAG "from the straight road and woke to find myself" -#define DESC_DEAD_TIME_TAG_LEN 46 - -// checks exectuable (returns !0 on error) -int SerialCheck(void); - -// given return value from SerialCheck() it reports the error -void SerialError(int error); - -// returns the serialnumber of the user -uint32_t SerialGetSerialNum(void); - -///////////////////////////////////////////////////////////////////////////// -// These are the functions used for serialization -// if this function returns: -// 1 : than it's a serialized exe, num will be given the serial num -// 0 : than it isn't a serialized exe -// -1 : detected a hacked exe -char GetInternalSerializationNumber(int *num); - -#endif diff --git a/Descent3/multi_client.cpp b/Descent3/multi_client.cpp index c44ae29c..98f25387 100644 --- a/Descent3/multi_client.cpp +++ b/Descent3/multi_client.cpp @@ -144,7 +144,6 @@ #include "pilot.h" #include "Mission.h" #include "stringtable.h" -#include "d3serial.h" #include "ship.h" #define WEAPONS_LOAD_UPDATE_INTERVAL 2.0 @@ -193,9 +192,8 @@ void MultiSendMyInfo() { memcpy(&data[count], Players[Player_num].tracker_id, len); count += len; } - int ser = 0; - GetInternalSerializationNumber(&ser); - MultiAddInt(ser, data, &count); + // Was serial + MultiAddInt(0, data, &count); // Send packets per second int pps = nw_ReccomendPPS(); diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index 12f1b0c2..be985a52 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -26,7 +26,6 @@ set(HEADERS ../descent3/ctlconfig.h ../descent3/ctlconfigtxt.h ../descent3/D3ForceFeedback.h - ../descent3/d3serial.h ../descent3/damage.h ../descent3/damage_external.h ../descent3/DeathInfo.h @@ -313,7 +312,6 @@ set(SOURCE ../descent3/D3ForceFeedback.cpp ../Descent3/d3movie.cpp ../Descent3/d3music.cpp - ../descent3/d3serial.cpp ../descent3/damage.cpp ../descent3/debuggraph.cpp ../descent3/dedicated_server.cpp