diff --git a/README.md b/README.md index 26000ca4..6205fc39 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ CoD4x is a modification of the Call of Duty 4 - Modern Warfare server. It fixes several bugs in the original binaries and allows developers to extend server functionality with additional variables and plugins. When using the CoD4x server, the clients invoke installation of the proprietary CoD4x client to players joining the server using the CoD4x servers, which fixes several known base game bugs in the client, and in combination with the server allows for extra features. A compatible client modification can be found here: [CoD4x_Client_pub](https://github.com/callofduty4x/CoD4x_Client_pub) -[Website](http://cod4x.me/) - [Forums](https://cod4x.me/index.php?/forums/) - [Documentation](http://docs.cod4x.me/) - [Masterserver](http://cod4master.cod4x.me/) +[Website](http://cod4x.ovh/) - [Forums](https://cod4x.ovh/index.php?/forums/) - [Documentation](http://docs.cod4x.ovh/) - [Masterserver](http://cod4master.cod4x.ovh/) ## The most prominent features are: * Administration commands @@ -11,13 +11,13 @@ A compatible client modification can be found here: [CoD4x_Client_pub](https://g * Pbss like screenshot feature * Automated client update, no manual installation needed * Backwards compatibility to 1.7 and 1.7a servers -* A new [masterserver](http://cod4master.cod4x.me/), for when the official masterserver is down +* A new [masterserver](http://cod4master.cod4x.ovh/), for when the official masterserver is down The CoD4x server can run on Windows and Linux. The CoD4x client update is only available for windows. ## Setting up a Call of Duty 4 server with Cod4x 1.8 -Download binaries: [Linux](https://cod4x.me/downloads/cod4x_server-linux.zip) [Windows](https://cod4x.me/downloads/cod4x_server-windows.zip) +Download binaries: [Releases](https://github.com/callofduty4x/CoD4x_Server/releases) You also require the base game to run a server. Copy every .iwd file in `cod4directory/main/` to `serverdirectory/main/`. Also copy everything inside `cod4directory/zone` to `serverdirectory/zone`. @@ -75,7 +75,7 @@ If compilation was successful the binary will be placed in the `/bin/` folder. ## Contributing CoD4x is licensed under the AGPL3 license. We welcome anybody to fork this project and submit a pull request. -Plugins can be written in C/C++ and we also provide language bindings for D. The `/plugins` directory contains some example plugins. You can contribute to the project by developing plugins and create a pull request for them and/or uploading and promoting them on the [forums](https://cod4x.me/forum/forum-17.html). +Plugins can be written in C/C++ and we also provide language bindings for D. The `/plugins` directory contains some example plugins. You can contribute to the project by developing plugins and create a pull request for them and/or uploading and promoting them on the [forums](https://cod4x.ovh/index.php?/forums/forum/5-server-plugins-and-management-tools/). If you want to contribute to the core project check the issue tracker for todos. We will try our best to keep the issue tracker filled with new bits. If you would like to work on a completely new feature, we would appreciate if you contact us first on the forums or on Github to discuss the idea. @@ -90,7 +90,7 @@ Aside from agreeing to the license, by making any use of CoD4x18 server you agre 2. The developers reserve the right to reuse your content as long as it is not used commercially. You have a right for your name/clan/website getting mentioned if this is going to happen. They can also use it on their own servers. -3. Maps you have installed on a server have to be either available on the internet already, or be made available to the community at the [CoD4x forums](https://cod4x.me/index.php?/forums/), with all required assets, like scripts, within 20 weeks of installation. You have to annouce your map on the [forums](https://cod4x.me/index.php?/forums/) on the same day you have installed it to gain the 20 weeks grace period. Not announced maps will have to be made available within 1 week. +3. Maps you have installed on a server have to be either available on the internet already, or be made available to the community at the [CoD4x forums](https://cod4x.ovh/index.php?/forums/), with all required assets, like scripts, within 20 weeks of installation. You have to annouce your map on the [forums](https://cod4x.ovh/index.php?/forums/) on the same day you have installed it to gain the 20 weeks grace period. Not announced maps will have to be made available within 1 week. 4. Plugins have to be made available as sourcecode so the user can interact with it @@ -99,4 +99,4 @@ Server's IPs violating these conditions can get permanently disabled. These conditions have been established to keep user created content open to everyone, and also to value the work on CoD4x. ## Everything else -Please check out the [forums](https://cod4x.me) and [our wiki](https://github.com/D4edalus/CoD4x_Server/wiki). +Please check out the [forums](https://cod4x.ovh) and [our wiki](https://github.com/callofduty4x/CoD4x_Server/wiki). diff --git a/README.txt b/README.txt index d29da9b2..6b728d2a 100644 --- a/README.txt +++ b/README.txt @@ -61,4 +61,4 @@ zlib is Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler CONTACT ======= -https://cod4x.me +https://cod4x.ovh diff --git a/dis/plugin_handler.c b/dis/plugin_handler.c deleted file mode 100644 index fab9beac..00000000 --- a/dis/plugin_handler.c +++ /dev/null @@ -1,1014 +0,0 @@ -#ifndef PLUGIN_HANDLER_C -#define PLUGIN_HANDLER_C - - - -#define P_P_F __attribute__((__noinline__)) __attribute__((__cdecl__)) - -pluginWrapper_t pluginFunctions; - -#include "plugin_com.c" - -void Plugin_Init() -{ - void *ptr; - int i; - pluginFunctions.loadedPlugins=0; - pluginFunctions.enabled=qfalse; - - Com_Printf("Plugin_Init: Plugins initialization successfull.\n"); - memset(&pluginFunctions,0x00,sizeof(pluginFunctions)); // 0 all data - pluginFunctions.enabled=qtrue; - - Cmd_AddCommand("loadPlugin", Plugin_LoadPlugin_f); - Cmd_AddCommand("unloadPlugin", Plugin_UnLoadPlugin_f); - Cmd_AddCommand("plugins", Plugin_PluginList_f); - Cmd_AddCommand("pluginInfo", Plugin_PluginInfo_f); -} -void Plugin_Load(char* name, size_t size) -{ - int i,j,nstrings; - char dll[256],*strings; - char* realpath; - void *lib_handle; - elf_data_t text; - pluginInfo_t info; - - if(!pluginFunctions.enabled){ - Com_Printf("Plugin handler is not initialized!\n"); - return; - - } - if(pluginFunctions.loadedPlugins>=MAX_PLUGINS-1){ - Com_Printf("Too many plugins loaded."); - return; - } - - if(size>128){ - Com_Printf("File name too long."); - return; - } - Com_DPrintf("Checking if the plugin is not already loaded...\n"); - // Check if the plugin is not already loaded... - for(i=0;i PLUGIN_HANDLER_VERSION){ - Com_PrintError("This plugin might not be compatible with this server version! Requested plugin handler version: %g, server's plugin handler version: %g. Unloading the plugin...\n",info.handlerVersion,PLUGIN_HANDLER_VERSION); - Plugin_Unload(i); - return; - } - else if(PLUGIN_HANDLER_VERSION - info.handlerVersion >= 0.1){ - Com_PrintWarning("This plugin might not be compatible with this server version! Requested plugin handler version: %g, server's plugin handler version: %g.\n",info.handlerVersion,PLUGIN_HANDLER_VERSION); - - } - - Com_Printf("Plugin %s loaded successfully. Server is currently running %d plugins.\n",pluginFunctions.plugins[i].name,pluginFunctions.loadedPlugins); - } - else{ - Com_PrintError("function OnInfoRequest not found in the plugin file. Unloading...\n"); - Plugin_Unload(i); - return; - - } - Com_Printf("Plugin %s loaded successfully. Server is currently running %d plugins.\n",pluginFunctions.plugins[i].name,pluginFunctions.loadedPlugins); - return; - } - - -} -void Plugin_Unload(int id) -{ - void *lib_handle; - int i; - if(pluginFunctions.plugins[id].loaded){ - if(pluginFunctions.plugins[id].exports != 0){ // Library-plugins cannot be unloaded, see plugins/readme.txt - Com_PrintError("Plugin_Unload: Cannot unload a library plugin!\n"); - return; - } - if(pluginFunctions.plugins[id].scriptfunctions != 0 || pluginFunctions.plugins[id].scriptmethods != 0){ - // Script-library plugins cannot be unloaded, see plugins/readme.txt - Com_PrintError("Plugin_Unload: Cannot unload a script-library plugin!\n"); - return; - } - if(pluginFunctions.plugins[id].OnUnload != NULL) - (*pluginFunctions.plugins[id].OnUnload)(); - // Remove all server commands of the plugin - for(i=0;i funcptrs[2]) - return i; - } - return -1; -} - -/*P_P_F int Plugin_CallerID() -{ - //asm volatile (""); // this + inline attribute prevents compiler optimization which removes the function call - int i,j; - void *funcptrs[3]; - char **names; - char buff[256]; - j = backtrace(funcptrs,3); - names = backtrace_symbols(funcptrs,j); - if(!names) - Com_Error(ERR_FATAL,"Function backtrace_symbols() is not working properly!"); - //Com_Printf("DEBUG: \"%s\",\"%s\",\"%s\".\n",names[0],names[1],names[2]); - if(strncmp(names[2],"plugins/",8)==0){ - j = strlen(names[2]); - for(i=8;i= PLUGINS_ITEMCOUNT){ - Com_DPrintf("Plugins: unknown event occured! Event ID: %d.\n",eventID); - return; - } - - va_list argptr; - - va_start(argptr, eventID); - void *arg_0 = va_arg(argptr, void*); - void *arg_1 = va_arg(argptr, void*); - void *arg_2 = va_arg(argptr, void*); - void *arg_3 = va_arg(argptr, void*); - void *arg_4 = va_arg(argptr, void*); - void *arg_5 = va_arg(argptr, void*); - - va_end(argptr); - - for(i=0;i < pluginFunctions.loadedPlugins; i++){ - if(pluginFunctions.plugins[i].OnEvent[eventID]!= NULL) - (*pluginFunctions.plugins[i].OnEvent[eventID])(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5); - } -} - - -/* -void Plugin_Event(int eventID, void *dataPt) -{ - int i=0; - - if(!pluginFunctions.enabled) - return; - - switch(eventID){ - case PLUGINS_ONPLAYERDC: - for(i=0;iinteger; -} -qboolean Plugin_IsSvRunning() -{ - if(com_sv_running) - return com_sv_running->boolean; - else - return qfalse; -} -void Plugin_ChatPrintf(int slot, char *fmt, ... ) -{ - //int ebp,*ptr; - char str[256]; - client_t *cl; - va_list vl; - - cl = slot >=0 ? &(svs.clients[slot]) : NULL; - va_start(vl,fmt); - vsprintf(str,fmt,vl); - va_end(vl); - SV_SendServerCommand(cl, "h \"%s\"", str); -} -void Plugin_BoldPrintf(int slot, char *fmt, ... ) -{ - char str[256]; - client_t *cl; - va_list vl; - cl = slot >=0 ? &(svs.clients[slot]) : NULL; - va_start(vl,fmt); - vsprintf(str,fmt,vl); - va_end(vl); - SV_SendServerCommand(cl, "c \"%s\"", str); -} -char *Plugin_GetPlayerName(int slot) -{ - return svs.clients[slot].name; -} -void Plugin_CmdExecute_f() -{ - Com_DPrintf("Attempting to execute a plugin command '%s'.\n",Cmd_Argv(0)); - if(!pluginFunctions.enabled){ - Com_DPrintf("Error! Tried executing a plugin command with plugins being disabled! Command name: '%s'.\n",Cmd_Argv(1)); - return; - } - char name[128]; - int i,j; - void (*func)(); - strcpy(name,Cmd_Argv(0)); - for(i=0;i=MAX_PLUGINS){ - Com_PrintError("Tried adding a command for a plugin with non existent pID. pID supplied: %d.\n",pID); - return; - }else if(pID<0){ - Com_PrintError("Plugin_AddServerCommand called from not within a plugin or from a disabled plugin!\n"); - return; - } - if(!pluginFunctions.plugins[pID].loaded){ - Com_PrintError("Tried adding a command for not loaded plugin! PID: %d.\n",pID); - } - Com_DPrintf("Adding a plugin command for plugin %d, command name: %s.\n",pID,name); - Cmd_AddCommand(name,Plugin_CmdExecute_f); - Cmd_SetPower(name, power); - pluginFunctions.plugins[pID].cmd[pluginFunctions.plugins[pID].cmds].xcommand = xcommand; - strcpy(pluginFunctions.plugins[pID].cmd[pluginFunctions.plugins[pID].cmds++].name,name); - Com_DPrintf("Command added.\n"); - // pluginFunctions.plugins[pID]. - - -} -void Plugin_RemoveCommand(int pID,char *name) -{ - int i,j,k; - j=pluginFunctions.plugins[pID].cmds; - for(i=0;i=MAX_PLUGINS){ - Com_Printf("Error: tried adding a script command for a plugin with non existent pID. pID supplied: %d.\n",pID); - return; - }else if(pID<0){ - Com_Printf("Plugin Handler error: Plugin_ScrAddFunction called from not within a plugin or from a disabled plugin!\n"); - return; - } - if(!pluginFunctions.plugins[pID].loaded){ - Com_Printf("Error: Tried adding a command for not loaded plugin! PID: %d.\n",pID); - } - Com_Printf("Adding a plugin script function for plugin %d, command name: %s.\n",pID,name); - Cmd_AddCommand(name, xcommand); - pluginFunctions.plugins[pID].cmd[pluginFunctions.functions[pID].cmds].xcommand = xcommand; - strcpy(pluginFunctions.plugins[pID].cmd[pluginFunctions.plugins[pID].cmds++].name,name); - Com_Printf("Command added.\n"); - // pluginFunctions.plugins[pID]. - - -} -void Plugin_ScrRemoveFunction(int pID,char *name) -{ - int i,j,k; - j=pluginFunctions.plugins[pID].cmds; - for(i=0;i\n", Cmd_Argv(0)); - return; - } - Plugin_Load(Cmd_Argv(1),128); -} -void Plugin_UnLoadPlugin_f() -{ - if( Cmd_Argc() < 2){ - Com_Printf("Usage: %s \n", Cmd_Argv(0)); - return; - } - Plugin_UnloadByName(Cmd_Argv(1),128); -} -void Plugin_PluginInfo_f() -{ - if(Cmd_Argc() < 2){ - Com_Printf("Usage: %s \n",Cmd_Argv(0)); - return; - } - int id = Plugin_GetID(Cmd_Argv(1),strlen(Cmd_Argv(1))); - int i; - pluginInfo_t info; - if(id<0){ - Com_Printf("Plugin \"%s\" is not loaded!\n",Cmd_Argv(1)); - return; - } - (*pluginFunctions.plugins[id].OnInfoRequest)(&info); - Com_Printf("\n"); - Com_Printf("\n^2Plugin name:^7\n%s\n\n",pluginFunctions.plugins[id].name); - Com_Printf("\n^2Plugin version:^7\n%g\n\n",info.pluginVersion); - Com_Printf("\n^2Full plugin name:^7\n%s\n\n",info.fullName); - Com_Printf("\n^2Short plugin description:^7\n%s\n\n",info.shortDescription); - Com_Printf("\n^2Full plugin description:^7\n%s\n\n",info.longDescription); - Com_Printf("\n^2Plugin commands:^7\n\n"); - for(i=0;i= PLUGIN_MAX_SOCKETS || connection < 0){ - Com_PrintError("Plugin_TcpConnect: Second argument can only be a value inside the range: 0...%d plugin ID: #%d\n", PLUGIN_MAX_SOCKETS); - return qfalse; - } - return Plugin_TcpConnect(pID, remote, connection); - -} - - -int Plugin_TcpGetData(int pID, int connection, void* buf, int size ) -{ - int len; - pluginTcpClientSocket_t* ptcs = &pluginFunctions.plugins[pID].sockets[connection]; - - if(ptcs->sock < 1){ - Com_PrintWarning("Plugin_TcpGetData: called on a non open socket for plugin ID: #%d\n", pID); - return -1; - } - len = NET_TcpGetData(&ptcs->sock, buf, size); - - return len; -} - - -P_P_F int Plugin_TcpGetData_p(int connection, void* buf, int size) -{ - int pID; - //Identify the calling plugin - pID = Plugin_CallerID(); - if(pID<0){ - Com_Printf("Plugin_TcpGetData: Error! Tried get TCP data for unknown plugin!\n"); - return -1; - } - if(pluginFunctions.plugins[pID].enabled==qfalse){ - Com_Printf("^1WARNING^7: Plugin_TcpGetData: Tried get TCP data for a disabled plugin!\n"); - return -1; - } - if(connection >= PLUGIN_MAX_SOCKETS || connection < 0){ - Com_PrintError("Plugin_TcpGetData: First argument can only be a value inside the range: 0...%d plugin ID: #%d\n", PLUGIN_MAX_SOCKETS, pID); - return -1; - } - if(buf == NULL){ - Com_PrintError("Plugin_TcpGetData: Third argument can not be a NULL-Pointer for plugin ID: #%d\n", pID); - return -1; - } - - return Plugin_TcpGetData(pID, connection, buf, size); -} - -qboolean Plugin_TcpSendData(int pID, int connection, void* data, int len) -{ - pluginTcpClientSocket_t* ptcs = &pluginFunctions.plugins[pID].sockets[connection]; - - if(ptcs->sock < 1){ - Com_PrintWarning("Plugin_TcpSendData: called on a non open socket for plugin ID: #%d\n", pID); - return qfalse; - } - return NET_TcpSendData(&ptcs->sock, data, len); - -} - - -P_P_F qboolean Plugin_TcpSendData_p(int connection, void* data, int len) -{ - - - int pID; - //Identify the calling plugin - pID = Plugin_CallerID(); - if(pID<0){ - Com_Printf("Plugin_TcpSendData: Error! Tried get TCP data for unknown plugin!\n"); - return qfalse; - } - if(pluginFunctions.plugins[pID].enabled==qfalse){ - Com_Printf("^1WARNING^7: Plugin_TcpSendData: Tried get TCP data for a disabled plugin!\n"); - return qfalse; - } - if(connection >= PLUGIN_MAX_SOCKETS || connection < 0){ - Com_PrintError("Plugin_TcpSendData: Second argument can only be a value inside the range: 0...%d plugin ID: #%d\n", PLUGIN_MAX_SOCKETS, pID); - return qfalse; - } - if(data == NULL){ - Com_PrintError("Plugin_TcpSendData: Second argument can not be a NULL-Pointer for plugin ID: #%d\n", pID); - return qfalse; - } - - return Plugin_TcpSendData(pID, connection, data, len); -} - - -void Plugin_TcpCloseConnection(int pID, int connection) -{ - pluginTcpClientSocket_t* ptcs = &pluginFunctions.plugins[pID].sockets[connection]; - - if(ptcs->sock < 1){ - Com_PrintWarning("Plugin_TcpCloseConnection: Called on a non open socket for plugin ID: #%d\n", pID); - return; - } - NET_TcpCloseConnection(&ptcs->sock); - -} - - -P_P_F void Plugin_TcpCloseConnection_p(int connection) -{ - int pID; - //Identify the calling plugin - pID = Plugin_CallerID(); - if(pID<0){ - Com_Printf("Plugin_TcpCloseConnection: Error! Tried get close a connection for unknown plugin!\n"); - return; - } - if(pluginFunctions.plugins[pID].enabled==qfalse){ - Com_Printf("^1WARNING^7: Plugin_TcpCloseConnection: Tried to close a connection for a disabled plugin!\n"); - return; - } - if(connection >= PLUGIN_MAX_SOCKETS || connection < 0){ - Com_PrintError("Plugin_TcpCloseConnection: Second argument can only be a value inside the range: 0...%d plugin ID: #%d\n", PLUGIN_MAX_SOCKETS, pID); - return; - } - Plugin_TcpCloseConnection(pID, connection); -} -*/ -P_P_F qboolean Plugin_UdpSendData_p(netadr_t* to, void* data, int len) -{ - int pID; - - if(to == NULL){ - pID = Plugin_CallerID(); - Com_PrintError("Plugin_UdpSendData: First argument can not be a NULL-Pointer for plugin ID: #%d\n", pID); - return qfalse; - } - - if(data == NULL){ - pID = Plugin_CallerID(); - Com_PrintError("Plugin_UdpSendData: First argument can not be a NULL-Pointer for plugin ID: #%d\n", pID); - return qfalse; - } - return Sys_SendPacket( len, data, to); -} - -P_P_F void Plugin_ServerPacketEvent_p(netadr_t* to, void* data, int len) -{ - msg_t msg; - msg.data = data; - msg.cursize = len; - msg.maxsize = len; - msg.bit = 0; - msg.overflowed = qfalse; - msg.readonly = qtrue; - - SV_PacketEvent( to, &msg ); -} - -P_P_F void Plugin_SetPlayerUID_p(unsigned int clientslot, unsigned int uid) -{ - client_t *cl; - if(!psvs.useuids){ - Plugin_Error(P_ERROR_TERMINATE, "Plugin tried to set UID while server don't work with UIDs\n"); - } - if(clientslot > sv_maxclients->integer) - { - Plugin_Error(P_ERROR_TERMINATE, va("Plugin tried to set UID for bad client: %d\n", clientslot)); - } - cl = &svs.clients[clientslot]; - cl->uid = uid; -} - -P_P_F unsigned int Plugin_GetPlayerUID_p(unsigned int clientslot) -{ - client_t *cl; - if(!psvs.useuids){ - Plugin_Error(P_ERROR_TERMINATE, "Plugin tried to get UID while server don't work with UIDs\n"); - } - if(clientslot > sv_maxclients->integer) - { - Plugin_Error(P_ERROR_TERMINATE, va("Plugin tried to get UID for bad client: %d\n", clientslot)); - } - cl = &svs.clients[clientslot]; - return cl->uid; -} - -P_P_F const char* Plugin_GetPlayerGUID_p(unsigned int clientslot) -{ - client_t *cl; - if(clientslot > sv_maxclients->integer) - { - Plugin_Error(P_ERROR_TERMINATE, va("Plugin tried to get GUID for bad client: %d\n", clientslot)); - } - cl = &svs.clients[clientslot]; - return cl->pbguid; -} - -P_P_F void Plugin_SetPlayerGUID_p(unsigned int clientslot, const char* guid) -{ - client_t *cl; - if(clientslot > sv_maxclients->integer) - { - Plugin_Error(P_ERROR_TERMINATE, va("Plugin tried to get GUID for bad client: %d\n", clientslot)); - } - cl = &svs.clients[clientslot]; - Q_strncpyz(cl->pbguid, guid, sizeof(cl->pbguid)); -} - -P_P_F void Plugin_SetPlayerNoPB_p(unsigned int clientslot) -{ - client_t *cl; - if(clientslot > sv_maxclients->integer) - { - Plugin_Error(P_ERROR_TERMINATE, va("Plugin tried to set No PunkBuster flag for bad client: %d\n", clientslot)); - } - cl = &svs.clients[clientslot]; - cl->noPb = qtrue; -} - -P_P_F int Plugin_DoesServerUseUids_p(void) -{ - return psvs.useuids; -} - -P_P_F void Plugin_SetServerToUseUids_p(int useuids) -{ - psvs.useuids = useuids; -} - -P_P_F int Plugin_GetLevelTime_p(void) -{ - return level.time; -} - -P_P_F int Plugin_GetServerTime_p(void) -{ - return svs.time; -} - - -#endif diff --git a/dis/plugin_handler.h b/dis/plugin_handler.h deleted file mode 100644 index dc4c54ee..00000000 --- a/dis/plugin_handler.h +++ /dev/null @@ -1,128 +0,0 @@ -#define MAX_PLUGINS 25 - -typedef void convariable_t; //For plugins - -#include -#include "plugins/plugin_declarations.h" -#include "elf32_parser.c" -#include "plugin_com.h" -//#include "plugin_events.c" - -#define PLUGIN_MAX_MALLOCS 50 -#define PLUGIN_MAX_SOCKETS 4 - -// plugins com -#define PLUGIN_COM_MAXNAMELEN 28 // Max 27 chars + \0 -#define PLUGIN_MAX_EXPORTS 50 // Maximum count of exported functions, each takes 32B of mem = 1kB per plugin - -enum { - PLUGIN_UNKNOWN = -1 -}; - -typedef struct{ - char name[32]; - xcommand_t xcommand; -}pluginCmd_t; - -typedef struct{ - size_t size; - void *ptr; -}pluginMem_t; - -typedef struct{ - char name[PLUGIN_COM_MAXNAMELEN]; - void *(*function)(); -}pluginExport_t; - -typedef struct{ - int sock; - netadr_t remote; - qboolean (*packetEventHandler)(netadr_t *from, msg_t* msg); -}pluginTcpClientSocket_t; - -typedef struct{ - int (*OnInit)(); // Initialization function - void (*OnInfoRequest)(); - - void (*OnEvent[PLUGINS_ITEMCOUNT])(); - void (*OnUnload)(); // De-initialization function - - pluginCmd_t cmd[20]; - pluginCmd_t scriptFunction[32]; - pluginCmd_t scriptMethod[32]; - int cmds; - int scriptfunctions; - int scriptmethods; - - char name[20]; - - pluginMem_t memory[PLUGIN_MAX_MALLOCS]; - pluginTcpClientSocket_t sockets[PLUGIN_MAX_SOCKETS]; - - pluginExport_t exportedFunctions[PLUGIN_MAX_EXPORTS]; - int exports; - - size_t usedMem; - int mallocs; - - qboolean loaded; - qboolean enabled; - - void *lib_handle; - void *lib_start; - long lib_size; - -}plugin_t; - -typedef struct{ - plugin_t plugins[MAX_PLUGINS]; - int loadedPlugins; - qboolean enabled; - qboolean initializing_plugin; -}pluginWrapper_t; - -void Plugin_Load(char*,size_t); -void Plugin_Unload(int id); -void Plugin_Event(int, ...); -void Plugin_Init(); -clientScoreboard_t Plugin_GetClientScoreboard(int); -int Plugin_Cmd_GetInvokerUid(); -int Plugin_GetPlayerUid(int); -int Plugin_GetSlotCount(); -qboolean Plugin_IsSvRunning(); -char *Plugin_GetPlayerName(int); -void Plugin_AddCommand(char *, xcommand_t, int power); -void *Plugin_Malloc(int,size_t); -void Plugin_Free(int,void *); -void Plugin_FreeAll(int); -void Plugin_Error(int, char *); -qboolean Plugin_TcpConnect(int,const char *,int); -int Plugin_TcpGetData(int, int, void*, int); -qboolean Plugin_TcpSendData(int,int, void*, int); -void Plugin_TcpCloseConnection(int,int); -int Plugin_CallerID(); - -void *Plugin_Malloc_p(size_t); -void Plugin_Free_p(void *); -qboolean Plugin_TcpConnect_p( int, const char *); -int Plugin_TcpGetData_p(int, void *, int); -qboolean Plugin_TcpSendData_p(int, void*, int); -void Plugin_TcpCloseConnection_p(int); -qboolean Plugin_UdpSendData_p(netadr_t* to, void* data, int len); -void Plugin_ServerPacketEvent_p(netadr_t* to, void* data, int len); -void Plugin_SetPlayerUID_p(unsigned int clientslot, unsigned int uid); -unsigned int Plugin_GetPlayerUID_p(unsigned int clientslot); -const char* Plugin_GetPlayerGUID_p(unsigned int clientslot); -void Plugin_SetPlayerGUID_p(unsigned int clientslot, const char* guid); -void Plugin_SetPlayerNoPB_p(unsigned int clientslot); -int Plugin_DoesServerUseUids_p(void); -void Plugin_SetServerToUseUids_p(int useuids); -int Plugin_GetLevelTime_p(void); -int Plugin_GetServerTime_p(void); - -void Plugin_LoadPlugin_f( void ); -void Plugin_UnLoadPlugin_f( void ); -void Plugin_PluginList_f( void ); -void Plugin_PluginInfo_f( void ); -void Plugin_ChatPrintf(int,char *,...); -void Plugin_BoldPrintf(int,char *,...); diff --git a/globalconfig.cfg b/globalconfig.cfg index d1693ea6..b2c87005 100644 --- a/globalconfig.cfg +++ b/globalconfig.cfg @@ -1,8 +1,7 @@ //CoD4X Global Config -set sv_masterservers "*cod4master.cod4x.me;cod4master.doszgep.cloud;" -set cl_updateservers "http://cod4update.cod4x.me/clupdate/" -set cl_filterlisturl "http://filter.cod4x.me/filter/" -set cl_cod4xsitedom "cod4x.me" -set sv_updateservers "http://cod4update.cod4x.me/svupdate/" -set r_rendererPreference "1" -writeconfig +set sv_masterservers "*cod4master.cod4x.ovh;cod4master.ax-servers.hu;" +set cl_updateservers "http://cod4update.cod4x.ovh/clupdate/" +set cl_filterlisturl "http://filter.cod4x.ovh/filter/" +set cl_cod4xsitedom "cod4x.ovh" +set sv_updateservers "http://cod4update.cod4x.ovh/svupdate/" + diff --git a/plugins/callback_declarations.h b/plugins/callback_declarations.h index 01e67ca7..636fca03 100644 --- a/plugins/callback_declarations.h +++ b/plugins/callback_declarations.h @@ -48,6 +48,7 @@ PCL void OnClientEnterWorld(client_t* client); PCL void OnClientUserinfoChanged(client_t* client); PCL void OnClientMoveCommand(client_t* client, usercmd_t* ucmd); + PCL void OnPlayerKilled(gentity_t* self, gentity_t* inflictor, gentity_t* attacker, int damage, int meansOfDeath, int iWeapon, hitLocation_t hitLocation); PCL void OnPlayerWantReservedSlot(netadr_t* from, char* pbguid, char* userinfo, int authstate, qboolean *isallowed); PCL void OnModuleLoaded(client_t* client, char* fullpath, long checksum); PCL void OnScreenshotArrived(client_t* client, const char* path); diff --git a/plugins/declarations.h b/plugins/declarations.h index 36cb4ca1..f27eaf5f 100644 --- a/plugins/declarations.h +++ b/plugins/declarations.h @@ -977,6 +977,28 @@ typedef struct { int longdata[1547]; } statData_t; +typedef enum hitLocation_t { + HITLOC_NONE = 0x0, + HITLOC_HELMET = 0x1, + HITLOC_HEAD = 0x2, + HITLOC_NECK = 0x3, + HITLOC_TORSO_UPR = 0x4, + HITLOC_TORSO_LWR = 0x5, + HITLOC_R_ARM_UPR = 0x6, + HITLOC_L_ARM_UPR = 0x7, + HITLOC_R_ARM_LWR = 0x8, + HITLOC_L_ARM_LWR = 0x9, + HITLOC_R_HAND = 0xA, + HITLOC_L_HAND = 0xB, + HITLOC_R_LEG_UPR = 0xC, + HITLOC_L_LEG_UPR = 0xD, + HITLOC_R_LEG_LWR = 0xE, + HITLOC_L_LEG_LWR = 0xF, + HITLOC_R_FOOT = 0x10, + HITLOC_L_FOOT = 0x11, + HITLOC_GUN = 0x12, + HITLOC_NUM = 0x13, +}hitLocation_t; #define MAX_ZPATH 256 diff --git a/plugins/function_declarations.h b/plugins/function_declarations.h index dd0fcb15..60490a7c 100644 --- a/plugins/function_declarations.h +++ b/plugins/function_declarations.h @@ -245,6 +245,7 @@ __cdecl short Plugin_Scr_GetConstString( unsigned int ); __cdecl unsigned int Plugin_Scr_GetType( unsigned int ); __cdecl void Plugin_Scr_GetVector( unsigned int, vec3_t* ); + __cdecl int Plugin_Scr_GetFunc( unsigned int paramnum ); __cdecl void Plugin_Scr_Error( const char *string); __cdecl void Plugin_Scr_ParamError( int, const char *string); __cdecl void Plugin_Scr_ObjectError( const char *string); @@ -368,4 +369,4 @@ __cdecl const char* Plugin_GetCommonVersionString(); //return cod4x version __cdecl level_locals_t* Plugin_GetLevelBase( ); - __cdecl void Plugin_UpdatePlayername(unsigned int clientnumber, const char* newname); \ No newline at end of file + __cdecl void Plugin_UpdatePlayername(unsigned int clientnumber, const char* newname); diff --git a/scriptdocumentation/MULTIPLE_SERVERS_TUTORIAL.md b/scriptdocumentation/MULTIPLE_SERVERS_TUTORIAL.md index ecef729a..c89165ad 100644 --- a/scriptdocumentation/MULTIPLE_SERVERS_TUTORIAL.md +++ b/scriptdocumentation/MULTIPLE_SERVERS_TUTORIAL.md @@ -72,4 +72,4 @@ TODO. Almost the same except 'start' command and .bat script extension. ## Launching servers -That's it. Now you can launch your servers using scripts inside `CoD4X`. You can always check your servers' visibility on http://cod4master.cod4x.me. +That's it. Now you can launch your servers using scripts inside `CoD4X`. You can always check your servers' visibility on http://cod4master.cod4x.ovh. diff --git a/src/asmsource/_g_missile.asm b/src/asmsource/_g_missile.asm index fbac0439..dcc99a2c 100644 --- a/src/asmsource/_g_missile.asm +++ b/src/asmsource/_g_missile.asm @@ -3111,6 +3111,21 @@ G_FireRocket_120: or [esi+0x180], eax mov [esp], esi call SV_LinkEntity + ; Emit missile_fire script event + push dword [edi] ; weapon name + call Scr_AddString + add esp, 0x4 + push esi + call Scr_AddEntity + add esp, 0x4 + push 2 + mov eax, scr_const + movzx eax, word [eax + 0x174] ; scr_const.missile_fire + push eax + push dword [ebp + 0x8] + call Scr_Notify + add esp, 0xC + mov eax, esi add esp, 0x7c pop ebx diff --git a/src/asmsource/pluginexports.asm b/src/asmsource/pluginexports.asm index bf9ba57c..eca7390c 100644 --- a/src/asmsource/pluginexports.asm +++ b/src/asmsource/pluginexports.asm @@ -136,6 +136,7 @@ pexport Scr_GetEntity pexport Scr_GetConstString pexport Scr_GetType pexport Scr_GetVector +pexport Scr_GetFunc pexport Scr_Error pexport Scr_ParamError pexport Scr_ObjectError @@ -175,4 +176,4 @@ pexport HTTP_CreateString_x_www_form_urlencoded pexport HTTP_ParseFormDataBody pexport HTTP_GetFormDataItem -ralias Plugin_UpdatePlayername, SV_UpdatePlayernameById \ No newline at end of file +ralias Plugin_UpdatePlayername, SV_UpdatePlayernameById diff --git a/src/common.c b/src/common.c index 36d21fcf..b617586c 100644 --- a/src/common.c +++ b/src/common.c @@ -169,6 +169,19 @@ void Com_ShutdownWorld(); void CM_Shutdown(); void Init_Watchdog(); +struct hunkUsed_t +{ + int permanent; + int temp; +}; +extern struct hunkUsed_t hunk_high; +extern struct hunkUsed_t hunk_low; +extern int s_hunkTotal; + +void HunkAvailMemDebug() +{ + Com_Printf(CON_CHANNEL_CLIENT, "Hunk available: %d, Hunk total: %d\n", (s_hunkTotal - hunk_high.temp + hunk_low.temp) / (1024*1024), s_hunkTotal / (1024*1024)); +} /* ================ @@ -740,7 +753,7 @@ void Com_Init(char* commandLine){ Com_StartupVariable(NULL); - Cvar_RegisterString ("_CoD4 X Site", "http://cod4x.me", CVAR_ROM | CVAR_SERVERINFO , ""); + Cvar_RegisterString ("_CoD4 X Site", "http://cod4x.ovh", CVAR_ROM | CVAR_SERVERINFO , ""); cvar_modifiedFlags &= ~CVAR_ARCHIVE; @@ -850,7 +863,7 @@ void Com_Init(char* commandLine){ Com_Printf(CON_CHANNEL_SYSTEM,"--- Common Initialization Complete ---\n"); - + HunkAvailMemDebug(); com_fullyInitialized = qtrue; Com_AddStartupCommands( ); diff --git a/src/cscr_const.cpp b/src/cscr_const.cpp index ce755f22..3247cbd1 100644 --- a/src/cscr_const.cpp +++ b/src/cscr_const.cpp @@ -195,6 +195,7 @@ extern "C" void __cdecl GScr_LoadConsts() scr_const.back_left = GScr_AllocString("back_left"); scr_const.back_right = GScr_AllocString("back_right"); scr_const.tag_gunner_pov = GScr_AllocString("tag_gunner_pov"); + scr_const.missile_fire = GScr_AllocString("missile_fire"); } diff --git a/src/db_load.cpp b/src/db_load.cpp index 91ffe733..b3df0b90 100644 --- a/src/db_load.cpp +++ b/src/db_load.cpp @@ -2103,12 +2103,7 @@ void DB_ReferencedFastFiles(char* g_zoneSumList, char* g_zoneNameList, int maxsi Q_strncat(g_zoneNameList, maxsize, " usermaps/"); Q_strncat(g_zoneNameList, maxsize, zone->zoneinfo.name); Q_strncat(g_zoneNameList, maxsize, "_load"); - } - Com_sprintf(checkSum, sizeof(checkSum), " %u", 496286); - Q_strncat(g_zoneSumList, maxsize, checkSum); - Q_strncat(g_zoneNameList, maxsize, " cod4x_ambfix"); - } @@ -4245,4 +4240,4 @@ void __cdecl Load_MaterialHandle(bool atStreamStart) } -}; \ No newline at end of file +}; diff --git a/src/filesystem.c b/src/filesystem.c index 9f482ddf..e044edab 100644 --- a/src/filesystem.c +++ b/src/filesystem.c @@ -2593,7 +2593,20 @@ static pack_t *FS_LoadZipFile( char *zipfile, const char *basename ) { unzGoToNextFile( uf ); } +/*//Code for dumping iwd pure sums + char headername[1024]; + sprintf(headername, "%s.sum", zipfile); + FILE* df = fopen(headername, "wb"); + if(df) + { + fwrite(fs_headerLongs, 4, fs_numHeaderLongs, df); + fclose(df); + }*/ + pack->checksum = Com_BlockChecksumKey32( fs_headerLongs, 4 * fs_numHeaderLongs, LittleLong( 0 ) ); + Com_Printf(CON_CHANNEL_DONT_FILTER, "%s: %d\n", zipfile, pack->checksum); + + if(fs_checksumFeed) pack->pure_checksum = Com_BlockChecksumKey32( fs_headerLongs, 4 * fs_numHeaderLongs, LittleLong( fs_checksumFeed ) ); else diff --git a/src/g_cmds.c b/src/g_cmds.c index 1b562085..1ac74966 100644 --- a/src/g_cmds.c +++ b/src/g_cmds.c @@ -950,7 +950,8 @@ void ClientCommand( int clientNum ) { } else if ( Q_stricmp( cmd, "entitycount" ) == 0 ) { Cmd_EntityCount_f( ent ); } else if ( Q_stricmp( cmd, "printentities" ) == 0 ) { - Cmd_PrintEntities_f( ent ); + // prevent clients sending this command, effectively dos'ing the server. + // Cmd_PrintEntities_f( ent ); } else { SV_GameSendServerCommand( clientNum, 0, va( "%c \"GAME_UNKNOWNCLIENTCOMMAND\x15%s\"", 101, cmd ) ); } diff --git a/src/g_scr_main_mp.cpp b/src/g_scr_main_mp.cpp index 8c45db48..b48da3d1 100644 --- a/src/g_scr_main_mp.cpp +++ b/src/g_scr_main_mp.cpp @@ -4,6 +4,7 @@ #include "cscr_stringlist.h" #include "stringed_interface.h" #include "bg_public.h" +#include "plugin_handler.h" #include @@ -334,6 +335,7 @@ void __cdecl GScr_AddEntity(gentity_s *pEnt) void __cdecl Scr_PlayerKilled(gentity_s *self, gentity_s *inflictor, gentity_s *attacker, int damage, int meansOfDeath, int iWeapon, const float *vDir, hitLocation_t hitLoc, int psTimeOffset, int deathAnimDuration) { + PHandler_Event(PLUGINS_ONPLAYERKILLED, self, inflictor, attacker, damage, meansOfDeath, iWeapon, hitLoc); uint16_t hitloc; const char *weapname; uint16_t callback; diff --git a/src/httpftp.c b/src/httpftp.c index 500e4371..07ab561d 100644 --- a/src/httpftp.c +++ b/src/httpftp.c @@ -1390,7 +1390,7 @@ static ftRequest_t* FTP_DLRequest(const char* url) if(user[0] == '\0' && passwd[0] == '\0') { Q_strncpyz(request->username, "anonymous", sizeof(request->username)); - Q_strncpyz(request->password, "cod4x@cod4x.me", sizeof(request->password)); + Q_strncpyz(request->password, "cod4x@cod4x.ovh", sizeof(request->password)); }else{ Q_strncpyz(request->username, user, sizeof(request->username)); Q_strncpyz(request->password, passwd, sizeof(request->password)); diff --git a/src/huffman.c b/src/huffman.c index e4b9e22e..466b62dc 100644 --- a/src/huffman.c +++ b/src/huffman.c @@ -112,267 +112,6 @@ static void Huff_Init( huff_t *huff ) { } - -int msg_hData[256] = { - 274054, //0 - 68777, //1 - 40460, //2 - 40266, //3 - 48059, //4 - 39006, //5 - 48630, //6 - 27692, //7 - 17712, //8 - 15439, //9 - 12386, //10 - 10758, //11 - 9420, //12 - 9979, //13 - 9346, //14 - 15256, //15 - 13184, //16 - 14319, //17 - 7750, //18 - 7221, //19 - 6095, //20 - 5666, //21 - 12606, //22 - 7263, //23 - 7322, //24 - 5807, //25 - 11628, //26 - 6199, //27 - 7826, //28 - 6349, //29 - 7698, //30 - 9656, //31 - 28968, //32 - 5164, //33 - 13629, //34 - 6058, //35 - 4745, //36 - 4519, //37 - 5199, //38 - 4807, //39 - 5323, //40 - 3433, //41 - 3455, //42 - 3563, //43 - 6979, //44 - 5229, //45 - 5002, //46 - 4423, //47 - 14108, //48 - 13631, //49 - 11908, //50 - 11801, //51 - 10261, //52 - 7635, //53 - 7215, //54 - 7218, //55 - 9353, //56 - 6161, //57 - 5689, //58 - 4649, //59 - 5026, //60 - 5866, //61 - 8002, //62 - 10534, //63 - 15381, //64 - 8874, //65 - 11798, //66 - 7199, //67 - 12814, //68 - 6103, //69 - 4982, //70 - 5972, //71 - 6779, //72 - 4929, //73 - 5333, //74 - 3503, //75 - 4345, //76 - 6098, //77 - 14117, //78 - 16440, //79 - 6446, //80 - 3062, //81 - 4695, //82 - 3085, //83 - 4198, //84 - 4013, //85 - 3878, //86 - 3414, //87 - 5514, //88 - 4092, //89 - 3261, //90 - 4740, //91 - 4544, //92 - 3127, //93 - 3385, //94 - 7688, //95 - 11126, //96 - 6417, //97 - 5297, //98 - 4529, //99 - 6333, //100 - 4210, //101 - 7056, //102 - 4658, //103 - 6190, //104 - 3512, //105 - 2843, //106 - 3479, //107 - 9369, //108 - 5203, //109 - 4980, //110 - 5881, //111 - 7509, //112 - 4292, //113 - 6097, //114 - 5492, //115 - 4648, //116 - 2996, //117 - 4988, //118 - 4163, //119 - 6534, //120 - 4001, //121 - 4342, //122 - 4488, //123 - 6039, //124 - 4827, //125 - 7112, //126 - 8654, //127 - 26712, //128 - 8688, //129 - 9677, //130 - 9368, //131 - 7209, //132 - 3399, //133 - 4473, //134 - 4677, //135 - 11087, //136 - 4094, //137 - 3404, //138 - 4176, //139 - 6733, //140 - 3702, //141 - 11420, //142 - 4867, //143 - 5968, //144 - 3475, //145 - 3722, //146 - 3560, //147 - 4571, //148 - 2720, //149 - 3189, //150 - 3099, //151 - 4595, //152 - 4044, //153 - 4402, //154 - 3889, //155 - 4989, //156 - 3186, //157 - 3153, //158 - 5387, //159 - 8020, //160 - 3322, //161 - 3775, //162 - 2886, //163 - 4191, //164 - 2879, //165 - 3110, //166 - 2576, //167 - 3693, //168 - 2436, //169 - 4935, //170 - 3017, //171 - 3538, //172 - 5688, //173 - 3444, //174 - 3410, //175 - 9170, //176 - 4708, //177 - 3425, //178 - 3273, //179 - 3684, //180 - 4564, //181 - 6957, //182 - 4817, //183 - 5224, //184 - 3285, //185 - 3143, //186 - 4227, //187 - 5630, //188 - 6053, //189 - 5851, //190 - 6507, //191 - 13692, //192 - 8270, //193 - 8260, //194 - 5583, //195 - 7568, //196 - 4082, //197 - 3984, //198 - 4574, //199 - 6440, //200 - 3533, //201 - 2992, //202 - 2708, //203 - 5190, //204 - 3889, //205 - 3799, //206 - 4582, //207 - 6020, //208 - 3464, //209 - 4431, //210 - 3495, //211 - 2906, //212 - 2243, //213 - 3856, //214 - 3321, //215 - 8759, //216 - 3928, //217 - 2905, //218 - 3875, //219 - 4382, //220 - 3885, //221 - 5869, //222 - 6235, //223 - 10685, //224 - 4433, //225 - 4639, //226 - 4305, //227 - 4683, //228 - 2849, //229 - 3379, //230 - 4683, //231 - 5477, //232 - 4127, //233 - 3853, //234 - 3515, //235 - 4913, //236 - 3601, //237 - 5237, //238 - 6617, //239 - 9019, //240 - 4857, //241 - 4112, //242 - 5180, //243 - 5998, //244 - 4925, //245 - 4986, //246 - 6365, //247 - 7930, //248 - 5948, //249 - 8085, //250 - 7732, //251 - 8643, //252 - 8901, //253 - 9653, //254 - 32647, //255 - -}; - static huff_t msgHuff; int MSG_ReadBitsCompress(const byte* input, int readsize, byte* outputBuf, int outputBufSize){ @@ -412,7 +151,7 @@ int MSG_WriteBitsCompress( const byte *datasrc, byte *buffdest, int bytecount){ } -static void Huff_BuildFromData(huff_t* huff, const int* msg_hData) +static void Huff_BuildFromData(huff_t* huff) { huff->blocNode = 513; huff->nodeList[511].parent = &huff->nodeList[512]; @@ -2738,5 +2477,5 @@ void Huffman_InitMain() { huffInit = qtrue; Huff_Init(&msgHuff); - Huff_BuildFromData(&msgHuff, msg_hData); + Huff_BuildFromData(&msgHuff); } diff --git a/src/msg.c b/src/msg.c index 5a65c52f..193fbf7e 100644 --- a/src/msg.c +++ b/src/msg.c @@ -3851,12 +3851,14 @@ void MSG_ReadDeltaHudElems(msg_t *msg, const int time, hudelem_t *from, hudelem_ MSG_ReadDeltaField(msg, time, &from[i], &to[i], &hudElemFields[y], 0, 0); } - for ( ; y < numFields; ++y ) - { + /* + for ( ; y < numFields; ++y ) + { int offset = hudElemFields[y].offset; ((byte*)&to[i])[offset] = ((byte*)&from[i])[offset]; } - + */ + assertx((!(from[i].alignOrg & ~15)), "(from[i].alignOrg) = %i", from[i].alignOrg); assertx((!(to[i].alignOrg & ~15)), "(to[i].alignOrg) = %i", to[i].alignOrg); @@ -3925,12 +3927,14 @@ void __cdecl MSG_ReadDeltaPlayerstate(const int localClientNum, msg_t *msg, cons MSG_ReadDeltaField(msg, time, from, to, &stateFields[i], print, noXor); } + /* for ( i = lc; i < numFields; ++i ) { int offset = stateFields[i].offset; *(uint32_t *)&((byte*)to)[offset] = *(uint32_t *)&((byte*)from)[offset]; } - + */ + if ( !readOriginAndVel ) { #ifndef DEDICATEDONLY diff --git a/src/player.h b/src/player.h index 3b429403..a85cfb6c 100644 --- a/src/player.h +++ b/src/player.h @@ -51,7 +51,8 @@ #define KEY_MASK_SMOKE 32768 #define KEY_MASK_NIGHTVISION 262144 #define KEY_MASK_ADS 524288 -#define KEY_MASK_USE 0x28 /* Combination */ +#define KEY_MASK_USE 8 +#define KEY_MASK_USERELOAD 0x20 #define BUTTON_ATTACK KEY_MASK_FIRE typedef struct{ diff --git a/src/plugin_events.h b/src/plugin_events.h index 7edcd8a5..029c94d7 100644 --- a/src/plugin_events.h +++ b/src/plugin_events.h @@ -49,6 +49,7 @@ enum PluginEvents{ PLUGINS_ONPOSTFASTRESTART, PLUGINS_ONCLIENTUSERINFOCHANGED, PLUGINS_ONCLIENTMOVECOMMAND, + PLUGINS_ONPLAYERKILLED, PLUGINS_ONPLAYERWANTRESERVEDSLOT, PLUGINS_ONFSSTARTED, PLUGINS_ONPLAYERGOTAUTHINFO, diff --git a/src/plugin_handler.c b/src/plugin_handler.c index 6b4b1689..28e196a5 100644 --- a/src/plugin_handler.c +++ b/src/plugin_handler.c @@ -64,6 +64,7 @@ char PHandler_Events[PLUGINS_ITEMCOUNT][32]={ "OnPostFastRestart", "OnClientUserinfoChanged", "OnClientMoveCommand", + "OnPlayerKilled", "OnPlayerWantReservedSlot", "OnFilesystemStarted", "OnPlayerGotAuthInfo", @@ -426,14 +427,17 @@ void PHandler_Event(int eventID,...) // Fire a plugin event, safe for use void *arg_3 = va_arg(argptr, void*); void *arg_4 = va_arg(argptr, void*); void *arg_5 = va_arg(argptr, void*); + void *arg_6 = va_arg(argptr, void*); + void *arg_7 = va_arg(argptr, void*); va_end(argptr); for(i=0;i < pluginFunctions.loadedPlugins; i++){ if(pluginFunctions.plugins[i].OnEvent[eventID]!= NULL){ pluginFunctions.hasControl = i; - (*pluginFunctions.plugins[i].OnEvent[eventID])(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5); + (*pluginFunctions.plugins[i].OnEvent[eventID])(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5, arg_6, arg_7); pluginFunctions.hasControl = PLUGIN_UNKNOWN; } } } + diff --git a/src/scr_vm.h b/src/scr_vm.h index ceec2ee9..3fb26fb4 100644 --- a/src/scr_vm.h +++ b/src/scr_vm.h @@ -368,6 +368,7 @@ typedef struct{ uint16_t back_left; uint16_t back_right; uint16_t tag_gunner_pov; + uint16_t missile_fire; }scr_const_t; extern scr_const_t scr_const; diff --git a/src/sec_sign.c b/src/sec_sign.c index e46fc6aa..332fe1c4 100644 --- a/src/sec_sign.c +++ b/src/sec_sign.c @@ -69,7 +69,7 @@ qboolean Sec_WriteCertificateToFile(sec_certificate_t *certificate, char *filena if(fp == NULL){ return qfalse; } - fputs("Signature File. Visit us at www.cod4x.me!",fp); + fputs("Signature File. Visit us at www.cod4x.ovh!",fp); fputc(0,fp); cert = certificate; do{ diff --git a/src/sec_update.h b/src/sec_update.h index af1715aa..1f162c3b 100644 --- a/src/sec_update.h +++ b/src/sec_update.h @@ -56,6 +56,6 @@ typedef struct sec_file_s{ #define SEC_UPDATE_DOWNLOAD(baseurl, qpath) "%s%s", baseurl, qpath #define SEC_UPDATE_GETVERSION "/?ver=%g&os=%s&build=%d&type=%c", SEC_VERSION, OS_STRING, Sys_GetBuild(), SEC_TYPE -#define UPDATE_SERVER_NAME "http://cod4update.cod4x.me/svupdate/" +#define UPDATE_SERVER_NAME "http://cod4update.cod4x.ovh/svupdate/" #endif diff --git a/src/server.h b/src/server.h index 37af2055..cd67e047 100644 --- a/src/server.h +++ b/src/server.h @@ -800,7 +800,6 @@ void SV_InitGameProgs(int a1); //sv_banlist.c void SV_InitBanlist( void ); -void SV_ReloadBanlist(); char* SV_PlayerIsBanned(uint64_t playerid, uint64_t steamid, netadr_t *addr, const char* name, char* message, int len); char* SV_PlayerBannedByip(netadr_t *netadr, char* message, int len); //Gets called in SV_DirectConnect void SV_PlayerAddBanByip(netadr_t *remote, char *message, int expire); diff --git a/src/stringed_ingame.cpp b/src/stringed_ingame.cpp index 98bed5a6..f4c86b3e 100644 --- a/src/stringed_ingame.cpp +++ b/src/stringed_ingame.cpp @@ -988,32 +988,25 @@ void SE_ShutDown(void) // // Any errors that result from this should probably be treated as game-fatal, since an asset file is fuxored. // -LPCSTR SE_LoadLanguage( LPCSTR psLanguage, SE_BOOL forceEnglish /* = SE_TRUE */ ) +LPCSTR SE_LoadLanguage( SE_BOOL forceEnglish /* = SE_TRUE */ ) { LPCSTR psErrorMessage = NULL; - if (psLanguage && psLanguage[0]) - { - SE_NewLanguage(); + SE_NewLanguage(); - string strResults; - /*int iFilesFound = */SE_BuildFileList( + string strResults; + /*int iFilesFound = */SE_BuildFileList( #ifdef _STRINGED - va("C:\\Source\\Tools\\StringEd\\test_data\\%s",sSE_STRINGS_DIR) + va("C:\\Source\\Tools\\StringEd\\test_data\\%s",sSE_STRINGS_DIR) #else - sSE_STRINGS_DIR + sSE_STRINGS_DIR #endif - , strResults); + , strResults); - LPCSTR p; - while ( (p=SE_GetFoundFile (strResults)) != NULL && !psErrorMessage ) - { - psErrorMessage = SE_Load( p, forceEnglish ); - } - } - else + LPCSTR p; + while ( (p=SE_GetFoundFile (strResults)) != NULL && !psErrorMessage ) { - __ASSERT( 0 && "SE_LoadLanguage(): Bad language name!" ); + psErrorMessage = SE_Load( p, forceEnglish ); } return psErrorMessage; diff --git a/src/stringed_ingame.h b/src/stringed_ingame.h index c77e9cf4..727a9eed 100644 --- a/src/stringed_ingame.h +++ b/src/stringed_ingame.h @@ -47,7 +47,9 @@ void SE_CheckForLanguageUpdates(void); int SE_GetNumLanguages ( void ); LPCSTR SE_GetLanguageName ( int iLangIndex ); // eg "german" LPCSTR SE_GetLanguageDir ( int iLangIndex ); // eg "strings/german" -LPCSTR SE_LoadLanguage ( LPCSTR psLanguage, SE_BOOL bLoadDebug = SE_TRUE ); +//LPCSTR SE_LoadLanguage ( LPCSTR psLanguage, SE_BOOL bLoadDebug = SE_TRUE ); +LPCSTR SE_LoadLanguage ( SE_BOOL forceEnglish ); + void SE_NewLanguage ( void ); } diff --git a/src/sv_banlist.c b/src/sv_banlist.c index e64f5e00..8e366b4b 100644 --- a/src/sv_banlist.c +++ b/src/sv_banlist.c @@ -202,13 +202,6 @@ char* SV_PlayerIsBanned(uint64_t playerid, uint64_t steamid, netadr_t *addr, con return NULL; } - -void SV_ReloadBanlist() -{ - -} - - void SV_InitBanlist() { ipbantime = Cvar_RegisterInt("banlist_maxipbantime", MAX_DEFAULT_IPBAN_MINUTES, 0, 20160, 0, "Limit of minutes to keep a ban against an ip-address up"); diff --git a/src/sv_bots.cpp b/src/sv_bots.cpp index 57852de9..f8ae8e17 100644 --- a/src/sv_bots.cpp +++ b/src/sv_bots.cpp @@ -29,8 +29,9 @@ const BotAction_t BotActions[] = { "sprint", KEY_MASK_SPRINT }, { "leanleft", KEY_MASK_LEANLEFT }, { "leanright", KEY_MASK_LEANRIGHT }, - { "ads", KEY_MASK_ADS_MODE }, - { "holdbreath", KEY_MASK_HOLDBREATH } + { "ads", KEY_MASK_ADS_MODE | KEY_MASK_ADS }, + { "holdbreath", KEY_MASK_HOLDBREATH }, + { "activate", KEY_MASK_USE } }; /* ================== diff --git a/src/sv_client.c b/src/sv_client.c index 9ecc7501..e029a475 100644 --- a/src/sv_client.c +++ b/src/sv_client.c @@ -196,6 +196,12 @@ __optimize3 __regparm1 void SV_DirectConnect( netadr_t *from ) { }else{ */ + if(cl->state == CS_CONNECTED) + { + Com_DPrintf(CON_CHANNEL_SERVER,"Rejected connection from %s. DoS attack detected by emulating client 1.8\n", NET_AdrToString(&cl->netchan.remoteAddress)); + return; + } + SV_DropClient( cl, "silent" ); newcl = cl; Com_Printf(CON_CHANNEL_SERVER,"reconnected: %s\n", NET_AdrToString(from)); @@ -237,7 +243,7 @@ __optimize3 __regparm1 void SV_DirectConnect( netadr_t *from ) { if(version < 9) { NET_OutOfBandPrint( NS_SERVER, from, "error\nThis server requires protocol version: %d\n" - "Please install the unofficial CoD4X-update you can find at http://cod4x.me\n", + "Please install the unofficial CoD4X-update you can find at http://cod4x.ovh\n", sv_protocol->integer); }else{ #ifdef BETA_RELEASE @@ -245,9 +251,17 @@ __optimize3 __regparm1 void SV_DirectConnect( netadr_t *from ) { "This is a beta server. Sorry, but you can not connect to it with a release build of CoD4X.\n", sv_protocol->integer); #else - NET_OutOfBandPrint( NS_SERVER, from, "error\nThis server requires protocol version: %d\n" - "Please restart CoD4 and see on the main-menu if a new update is available\n" - "{OOBErrorParser protocolmismatch CoD4X" Q3_VERSION " %d}", sv_protocol->integer, sv_protocol->integer); + if(version >= 21) + { + NET_OutOfBandPrint( NS_SERVER, from, "error\nThis server requires protocol version: %d\n" + "Please restart CoD4 and see on the main-menu if a new update is available\n" + "{OOBErrorParser protocolmismatch CoD4X" Q3_VERSION " %d}", sv_protocol->integer, sv_protocol->integer); + }else{ + NET_OutOfBandPrint( NS_SERVER, from, "error\nThis server requires protocol version: %d\n" + "To update to protocol version 21 please look in CoD4X serverlist (ingame server browser) for an updating-server\n" + "or install the new client update manually from https://cod4x.ovh\n" + "Note: Ingame autoupdate will not work", sv_protocol->integer); + } #endif } Com_Printf(CON_CHANNEL_SERVER,"rejected connect from version %i\n", version); @@ -518,7 +532,7 @@ __optimize3 __regparm1 void SV_DirectConnect( netadr_t *from ) { } if(svs.time - newcl->updateBeginTime > 18000) { - NET_OutOfBandPrint( NS_SERVER, from, "error\n%s\n", "Can not connect to server because the update backend is unavailable\nTo join this server you have to install the required update manually.\nPlease visit www.cod4x.me/clupdate"); + NET_OutOfBandPrint( NS_SERVER, from, "error\n%s\n", "Can not connect to server because the update backend is unavailable\nTo join this server you have to install the required update manually.\nPlease visit www.cod4x.ovh/clupdate"); Com_Printf(CON_CHANNEL_SERVER,"Rejected client %s because updatebackend is unavailable\n", nick); SV_FreeClientScriptId(newcl); Com_Memset(newcl, 0, sizeof(client_t)); diff --git a/src/sv_main.c b/src/sv_main.c index 04405b6c..604a992a 100644 --- a/src/sv_main.c +++ b/src/sv_main.c @@ -1544,7 +1544,7 @@ __optimize3 __regparm2 static void SVC_RemoteCommand( netadr_t *from, msg_t *msg } #ifdef COD4X18UPDATE -#define UPDATE_PROXYSERVER_NAME "cod4update.cod4x.me" +#define UPDATE_PROXYSERVER_NAME "cod4update.cod4x.ovh" #define UPDATE_PROXYSERVER_PORT_RELEASE 27953 #define UPDATE_PROXYSERVER_PORT_BETA 27954 #define UPDATE_PROXYSERVER_PORT_RC 27955 @@ -1998,8 +1998,16 @@ __optimize3 __regparm2 void SV_PacketEvent( netadr_t *from, msg_t *msg ) { Com_Printf(CON_CHANNEL_SERVER,"Invalid reliableAcknowledge message from %s - reliableAcknowledge is %i\n", cl->name, cl->reliableAcknowledge); return; } + cl->reliableAcknowledge = MSG_ReadLong( msg ); + if (cl->reliableAcknowledge < 0) + { + Com_Printf(CON_CHANNEL_SERVER,"Negative reliableAcknowledge message from %s - reliableAcknowledge is %i\n", cl->name, cl->reliableAcknowledge); + cl->reliableAcknowledge = cl->reliableSequence; + return; + } + if((cl->reliableSequence - cl->reliableAcknowledge) > (MAX_RELIABLE_COMMANDS - 1)){ Com_Printf(CON_CHANNEL_SERVER,"Out of range reliableAcknowledge message from %s - reliableSequence is %i, reliableAcknowledge is %i\n", cl->name, cl->reliableSequence, cl->reliableAcknowledge); @@ -3109,7 +3117,7 @@ void SV_InitCvarsOnce(void){ sv_shownet = Cvar_RegisterInt("sv_shownet", -1, -1, 63, 0, "Enable network debugging for a client"); sv_updatebackendname = Cvar_RegisterString("sv_updatebackendname", UPDATE_PROXYSERVER_NAME, CVAR_ARCHIVE, "Hostname for the used clientupdatebackend"); sv_legacymode = Cvar_RegisterBool("sv_legacyguidmode", qfalse, CVAR_ARCHIVE, "outputs pbguid on status command and games_mp.log"); - sv_authtoken = Cvar_RegisterString("sv_authtoken", "", 0, "Token to register on masterserver. You can get it from http://cod4master.cod4x.me"); + sv_authtoken = Cvar_RegisterString("sv_authtoken", "", 0, "Token to register on masterserver. You can get it from http://cod4master.cod4x.ovh"); sv_disableChat = Cvar_RegisterBool("sv_disablechat", qfalse, CVAR_ARCHIVE, "Disable chat messages from clients"); } @@ -3497,11 +3505,6 @@ qboolean SV_FFAPlayerCanBlock(){ //Few custom added things which should happen if we load a new level or restart a level void SV_PreLevelLoad(){ - - client_t* client; - int i; - char buf[MAX_STRING_CHARS]; - Com_UpdateRealtime(); time_t realtime = Com_GetRealtime(); char *timestr = ctime(&realtime); @@ -3519,29 +3522,9 @@ void SV_PreLevelLoad(){ FS_ShutdownIwdPureCheckReferences(); - SV_ReloadBanlist(); - NV_LoadConfig(); - for ( client = svs.clients, i = 0 ; i < sv_maxclients->integer ; i++, client++ ) { - - // send the new gamestate to all connected clients - if ( client->state < CS_ACTIVE ) { - continue; - } - - if ( client->netchan.remoteAddress.type == NA_BOT ) { - continue; - } - - if(SV_PlayerIsBanned(client->playerid, client->steamid, &client->netchan.remoteAddress, client->name, buf, sizeof(buf))){ - SV_DropClient(client, "Prior kick/ban"); - continue; - } - } - HL2Rcon_EventLevelStart(); - } void SV_PostLevelLoad(){ @@ -4078,7 +4061,7 @@ void SV_BotUserMove(client_t *client) } if (shouldSpamUseButton(ent)) - ucmd.buttons |= KEY_MASK_USE; + ucmd.buttons |= KEY_MASK_USE | KEY_MASK_USERELOAD; client->deltaMessage = client->netchan.outgoingSequence - 1; SV_ClientThink(client, &ucmd); diff --git a/src/unix/sys_unix.c b/src/unix/sys_unix.c index 1697b4f2..39e13d2c 100644 --- a/src/unix/sys_unix.c +++ b/src/unix/sys_unix.c @@ -570,7 +570,7 @@ void Sys_LoadLibraryError(char* errormessage, int maxlen) void* Sys_LoadLibrary(const char* dlfile) { - void* handle = dlopen(dlfile, RTLD_LAZY); + void* handle = dlopen(dlfile, RTLD_NOW); currentLibHandle = handle; if(handle == NULL) { diff --git a/src/version/version.c b/src/version/version.c index 7c26a0d8..7491394c 100644 --- a/src/version/version.c +++ b/src/version/version.c @@ -1,6 +1,6 @@ #include "version.h" -#define SYS_COMMONVERSION 20.1 +#define SYS_COMMONVERSION 21.2 #define _STRINGIFY(s) #s #define STRINGIFY(s) _STRINGIFY(s) diff --git a/src/win32/win_syscon.c b/src/win32/win_syscon.c index a6d940ce..5db402e6 100644 --- a/src/win32/win_syscon.c +++ b/src/win32/win_syscon.c @@ -81,7 +81,6 @@ typedef struct HBITMAP hbmClearBitmap; HBRUSH hbrEditBackground; - HBRUSH hbrErrorBackground; HFONT hfBufferFont; HFONT hfButtonFont; @@ -155,12 +154,10 @@ static LONG WINAPI ConWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara break; case WM_CLOSE: - Cbuf_AddText("quit\n"); - return 0; case WM_CTLCOLORSTATIC: if ( ( HWND ) lParam == s_wcd.hwndBuffer ) { - SetBkColor( ( HDC ) wParam, RGB( 0x33, 0x33, 0x33 ) ); + SetBkColor( ( HDC ) wParam, RGB( 0, 0, 0 ) ); SetTextColor( ( HDC ) wParam, RGB( 0xff, 0xff, 0xff ) ); #if 0 // this draws a background in the edit box, but there are issues with this @@ -174,16 +171,6 @@ static LONG WINAPI ConWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara } #endif return ( long ) s_wcd.hbrEditBackground; - } else if ( ( HWND ) lParam == s_wcd.hwndErrorBox ) { - if ( s_timePolarity & 1 ) { - SetBkColor( ( HDC ) wParam, RGB( 0x80, 0x80, 0x80 ) ); - SetTextColor( ( HDC ) wParam, RGB( 0xff, 0x0, 0x00 ) ); - } else - { - SetBkColor( ( HDC ) wParam, RGB( 0x80, 0x80, 0x80 ) ); - SetTextColor( ( HDC ) wParam, RGB( 0x00, 0x0, 0x00 ) ); - } - return ( long ) s_wcd.hbrErrorBackground; } break; @@ -208,8 +195,7 @@ static LONG WINAPI ConWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara case WM_CREATE: // s_wcd.hbmLogo = LoadBitmap( g_wv.hInstance, MAKEINTRESOURCE( IDB_BITMAP1 ) ); // s_wcd.hbmClearBitmap = LoadBitmap( g_wv.hInstance, MAKEINTRESOURCE( IDB_BITMAP2 ) ); - s_wcd.hbrEditBackground = CreateSolidBrush( RGB( 0x33, 0x33, 0x33 ) ); - s_wcd.hbrErrorBackground = CreateSolidBrush( RGB( 0x80, 0x80, 0x80 ) ); + s_wcd.hbrEditBackground = CreateSolidBrush( RGB( 0, 0, 0 ) ); SetTimer( hWnd, 1, 1000, NULL ); break; case WM_ERASEBKGND: diff --git a/src/xac_helper.c b/src/xac_helper.c index 2c2d1112..9d4f2624 100644 --- a/src/xac_helper.c +++ b/src/xac_helper.c @@ -346,4 +346,5 @@ void SV_RunFrameXAC() { if(xac_imp.RunFrame) xac_imp.RunFrame(); -} \ No newline at end of file +} + diff --git a/tools/cod4_dasm/cod4_dasm.cc b/tools/cod4_dasm/cod4_dasm.cc index 7db161c0..a1980fb6 100644 --- a/tools/cod4_dasm/cod4_dasm.cc +++ b/tools/cod4_dasm/cod4_dasm.cc @@ -742,7 +742,6 @@ class ShadowFileMap { if(sym1->address < sym2->address) return -1; if(sym1->address > sym2->address) return 1; - printf("Error: Duplicate address detected\n"); exit(1);