| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts 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 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 <http://www.gnu.org/licenses/>.
- */
- /******************************************************************************
- *
- * FILE
- *
- * DESCRIPTION
- *
- * PROGRAMMER
- * Denzil E. Long, Jr.
- *
- * VERSION INFO
- * $Author: Patrick $
- * $Revision: 10 $
- * $Modtime: 8/29/01 4:04p $
- * $Archive: /Commando/Code/Scripts/DLLmain.cpp $
- *
- ******************************************************************************/
- #include "Windows.H"
- #include "scripts.h"
- #include "scriptregistrar.h"
- //#include "missioncontrol.h"
- #include "dprint.h"
- /******************************************************************************
- *
- * NAME
- * DllMain
- *
- * DESCRIPTION
- * Main DLL entry point
- *
- * INPUTS
- * HINSTANCE hinst
- * DWORD reason
- * LPVOID
- *
- * RESULTS
- * BOOL APIENTRY
- *
- ******************************************************************************/
- __declspec(dllexport)
- BOOL APIENTRY DllMain(HINSTANCE hinst, DWORD reason, LPVOID)
- {
- if (reason == DLL_PROCESS_ATTACH) {
- // DebugPrint("\n========== Script.dll loaded ==========\n");
- DebugPrint("Total registered scripts: %d\n", ScriptRegistrar::Count());
- } else if (reason == DLL_PROCESS_DETACH) {
- // DebugPrint("\n========== Script.dll Unloaded ==========\n");
- }
- return TRUE;
- }
- /******************************************************************************
- *
- * NAME
- * Create_Script
- *
- * DESCRIPTION
- * DLL entry to create a script instance.
- *
- * INPUTS
- * const char* name
- *
- * RESULTS
- * ScriptClass*
- *
- ******************************************************************************/
- ScriptClass* Create_Script(const char* name)
- {
- return ScriptRegistrar::CreateScript(name);
- }
- /******************************************************************************
- *
- * NAME
- * Destroy_Script
- *
- * DESCRIPTION
- * DLL entry to destroy a script instance
- *
- * INPUTS
- * ScriptClass* script
- *
- * RESULTS
- * NONE
- *
- ******************************************************************************/
- void Destroy_Script(ScriptClass* script)
- {
- assert(script != NULL);
- delete script;
- }
- /******************************************************************************
- *
- * NAME
- * Get_Script_Count
- *
- * DESCRIPTION
- * DLL entry to count the number of registered scripts
- *
- * INPUTS
- * NONE
- *
- * RESULTS
- * Count
- *
- ******************************************************************************/
- int Get_Script_Count(void)
- {
- return ScriptRegistrar::Count();
- }
- /******************************************************************************
- *
- * NAME
- * Get_Script_Name
- *
- * DESCRIPTION
- * DLL entry to retrieve script name.
- *
- * INPUTS
- * int index
- *
- * RESULTS
- * const char*
- *
- ******************************************************************************/
- const char* Get_Script_Name(int index)
- {
- ScriptFactory* factory = ScriptRegistrar::GetScriptFactory(index);
- if (factory != NULL) {
- return factory->GetName();
- }
- return NULL;
- }
- /******************************************************************************
- *
- * NAME
- * Get_Script_Param_Description
- *
- * DESCRIPTION
- * DLL entry to retrieve Script parameter description.
- *
- * INPUTS
- * int index
- *
- * RESULTS
- * const char*
- *
- ******************************************************************************/
- const char* Get_Script_Param_Description(int index)
- {
- ScriptFactory* factory = ScriptRegistrar::GetScriptFactory(index);
- if (factory != NULL) {
- return factory->GetParamDescription();
- }
- return NULL;
- }
- /******************************************************************************
- *
- * NAME
- * Set_Script_Commands
- *
- * DESCRIPTION
- * DLL entry to initialize script commands hooks.
- *
- * INPUTS
- * ScriptCommandsClass* commands
- *
- * RESULTS
- * Success - True if successful; otherwise false.
- *
- ******************************************************************************/
- bool Set_Script_Commands(ScriptCommandsClass* commands)
- {
- assert(commands != NULL);
- // Save the commands list
- Commands = commands->Commands;
- DebugPrint("Setting script commands (Version %d, Size %d)\n",
- Commands->Version, Commands->Size);
- // Check the commands version number
- if ((Commands->Size != sizeof(ScriptCommands))
- || (Commands->Version != SCRIPT_COMMANDS_VERSION)) {
- DebugPrint("***** Invalid script commands (Expected Version %d, Size %d)\n",
- SCRIPT_COMMANDS_VERSION, sizeof(ScriptCommands));
- Commands->Debug_Message("******** Incorrect Script Commands Version\n");
- return false;
- }
- return true;
- }
- /******************************************************************************
- *
- * NAME
- * Set_Request_Destroy_Func
- *
- * DESCRIPTION
- *
- * INPUTS
- * Function
- *
- * RESULTS
- * NONE
- *
- ******************************************************************************/
- void Set_Request_Destroy_Func(void (*function)(ScriptClass*))
- {
- assert(function != NULL);
- ScriptImpClass::Set_Request_Destroy_Func(function);
- }
|