Compare commits

...
23 Commits
Author SHA1 Message Date
L 16d9a6f8b0 TriggerChangeLevel: fix crash 2023-01-30 17:43:50 +01:00
L 65475f6bcc Terrain trace freeze fix 2023-01-30 17:19:12 +01:00
L a71c6db442 Using a definite stable version of MEM_BlockAlloc 2023-01-30 17:11:44 +01:00
L 1354224f58 TIKI_RegisterTikiFlags: key value fix 2023-01-30 16:30:45 +01:00
L d51aa53309 Misc comments 2023-01-30 16:28:15 +01:00
L 3b5131faef Crash fix when decompressing a compressed archive (like .pth file) 2023-01-30 16:28:01 +01:00
L de2606005c Alias_ListFindRandomRange: fix crash because of wrong index 2023-01-30 16:27:38 +01:00
L 9fcdc0f118 CMake: add _CRT_NONSTDC_NO_DEPRECATE for MSVC 2023-01-30 16:27:15 +01:00
L ab1b6ae409 Fixed crash when inactive player gets kicked 2023-01-30 16:26:53 +01:00
L fbac483f60 Fixed archive crash on x64 2023-01-30 16:26:38 +01:00
L 8843210e74 Refactored MSG_WriteDeltaEntity / MSG_WriteDeltaPlayerstate
Added netFieldType_e enum
2023-01-30 14:32:51 +01:00
L 2fa5bccbb4 Fixed rare 'bad command byte' error after executing a client command 2023-01-30 14:13:43 +01:00
L 58c8e743d2 added sv.frameTime variable on server (passed as a parameter on WriteDeltaEntity/WriteDeltaPlayerState) 2023-01-30 14:12:37 +01:00
L edd18be095 Fixed macro redefinition 2023-01-30 14:11:41 +01:00
L c0dc08740f Added >= 2.0 stuff in msg code 2023-01-30 03:00:39 +01:00
L 4d82fb29cb Removed useless "context switching" feature
Tidied up code
2023-01-30 00:50:21 +01:00
L 8366a2b320 Removed deprecated tool that has nothing to do with opm 2023-01-30 00:44:10 +01:00
L 2417fe8a01 Removed cgame_hook from OpenMoHAA 2023-01-30 00:28:14 +01:00
L bea6f39207 optimization for GetBoneFrame: return a reference instead of a copy 2023-01-30 00:26:30 +01:00
L 9ada899127 SV_AddEntToSnapshot: added portalEnt and portalSky parameters 2023-01-30 00:24:38 +01:00
L 9c70903b94 Fixed compiler warnings on x64 2023-01-30 00:24:16 +01:00
L 3e23ed9e24 Fixed compiler warnings on x64 due to HashCode returning an int 2023-01-30 00:24:07 +01:00
L 95a244fde0 Fixed compiler warnings by removing tiki.h inclusion from qcommon.h 2023-01-30 00:23:47 +01:00
145 changed files with 6725 additions and 43747 deletions

No files matched your search

+3 -1
View File
@@ -74,7 +74,9 @@ endif()
set(TARGET_BASE_GAME "main${TARGET_BASE_SUFFIX}")
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
if(MSVC)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
endif()
IF(${CMAKE_C_COMPILER_ARCHITECTURE_ID} STREQUAL "x64") # for desktop
set(TARGET_ARCH_SUFFIX "x64")
+2
View File
@@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef __CG_PUBLIC_H__
#define __CG_PUBLIC_H__
#include <tiki.h>
#define CMD_BACKUP 128
#define CMD_MASK (CMD_BACKUP - 1)
// allow a lot of command backups for very fast systems
-1
View File
@@ -1 +0,0 @@
#include "script/canimate.h"
-183
View File
@@ -1,183 +0,0 @@
#ifndef __ASM_H__
#define __ASM_H__
#if defined ( CGAME_DLL )
#define _CGAME_CODE() if(1)
#else
#define _CGAME_CODE() if(0)
#endif
#if defined ( WIN32 )
#define _LINUX_CODE() if(0)
#define WIN32_CODE() if(1)
#else
#define _CGAME_CODE() if(0)
#define _LINUX_CODE() if(1)
#define WIN32_CODE() if(0)
#endif
#ifdef WIN32
#define NAKED __declspec(naked)
#else
#define NAKED
#endif
#ifdef __GNUC__
#define JMPTO( addr ) asm("leave;mov %0, %%edx;jmp *%%edx;" : : "g"((DWORD)addr) )
#define JMPTO_DIRECT( addr ) asm("movl %0, %%edx;jmp *%%edx;" : : "g"((DWORD)addr) )
#define CALL( addr ) asm("movl %0, %%edx;call *%%edx;" : : "g"((DWORD)addr) ) //{ DWORD address_CALL = (DWORD) addr; __asm__ __volatile__("movl %0, %%edx;call *%%edx;" : : "g"(address_CALL) ); }
#define PUSH( addr ) asm("pushl %0;" : : "g"(*(DWORD *)&addr) ) //{ DWORD address_PUSH = (DWORD) addr; __asm__ __volatile__("push %0;" :: "g"(address_PUSH)); }
#define POP( addr ) asm("popl %0;" : : "g"(*(DWORD *)&addr) ) //{ DWORD address_PUSH = (DWORD) addr; __asm__ __volatile__("push %0;" :: "g"(address_PUSH)); }
#ifndef WIN32
#define SET_CLASS( addr ) asm("movl %0, %%eax; movl %%eax, (%%esp);" : : "g"((DWORD)addr) ) // asm("movl %0, %%ecx;" : : "g"(addr) ) //{ DWORD address_SET_CLASS = (DWORD) addr; __asm__ __volatile__("movl %0, %%ecx;" : : "g"(address_SET_CLASS) ); }
#define GET_CLASS( var ) asm("movl %%esp, %0;" : "=r"(var) )
#else
#define SET_CLASS( addr ) asm("movl %0, %%ecx;" : : "g"((DWORD)addr) ) // asm("movl %0, %%ecx;" : : "g"(addr) ) //{ DWORD address_SET_CLASS = (DWORD) addr; __asm__ __volatile__("movl %0, %%ecx;" : : "g"(address_SET_CLASS) ); }
#define GET_CLASS( var ) asm("movl %%ecx, %0;" : "=r"(var) )
#endif
#define MAKE_JUMPER( declaration, gamex86_address, fgameded_symbol, cgamex86_address ) declaration {} //asm( ".globl " #fgameded_symbol "\n\t" #fgameded_symbol ":\n\tmovl _" #fgameded_symbol "_, %edx;jmp *%edx;" )
#else
#define JMPTO( addr ) { _asm leave _asm mov edx, addr _asm jmp edx }
#define JMPTO_DIRECT( addr ) { _asm mov edx, addr _asm jmp edx }
#define CALL( addr ) { _asm mov edx, addr _asm call edx }
#define PUSH( addr ) { _asm push addr }
#define POP( addr ) { _asm pop addr }
#define SET_CLASS( addr ) { _asm mov ecx, addr }
#define GET_CLASS( var ) { _asm mov var, ecx }
#define MAKE_JUMPER( declaration, gamex86_address, fgameded_symbol, cgamex86_address ) \
__declspec(naked) declaration { JMPTO_DIRECT_WIN32( gamex86_address) JMPTO_DIRECT_CGAME( cgamex86_address ) }
#endif
#if defined ( _UBER_SDK )
#define MP_NUMBER( gamex86, fgameded, cgamex86 ) 0
#define MP_STRING( gamex86, fgameded, cgamex86 ) 0
#endif
#if defined ( CGAME_DLL )
#define MP_NUMBER( gamex86, fgameded, cgamex86 ) cgamex86
#define MP_STRING( gamex86, fgameded, cgamex86 ) cgamex86
#define JMPTO_CGAME(addr) JMPTO(addr)
#define JMPTO_DIRECT_CGAME(addr) JMPTO_DIRECT(addr)
#if defined( SPEARHEAD ) || defined( SH )
#define JMPTO_SH_CGAME(addr) JMPTO(addr)
#define JMPTO_SH_DIRECT_GAME(addr) JMPTO_DIRECT(addr)
#else
#define JMPTO_SH_CGAME(addr)
#define JMPTO_SH_DIRECT_GAME(addr)
#endif
#if defined( BREAKTHROUGH ) || defined( BT )
#define JMPTO_BT_CGAME(addr) JMPTO(addr)
#define JMPTO_BT_DIRECT_GAME(addr) JMPTO_DIRECT(addr)
#else
#define JMPTO_BT_CGAME(addr)
#define JMPTO_BT_DIRECT_GAME(addr)
#endif
#define CALL_CGAME(addr) CALL(addr)
#else
#define JMPTO_CGAME(addr)
#define JMPTO_DIRECT_CGAME(addr)
#define CALL_CGAME(addr) CALL(addr)
#define JMPTO_SH_CGAME(addr)
#define JMPTO_SH_DIRECT_GAME(addr)
#define JMPTO_BT_CGAME(addr)
#define JMPTO_BT_DIRECT_GAME(addr)
#endif
#if !defined( SPEARHEAD ) && !defined( SH )
#define JMPTO_SH_WIN32(addr)
#define JMPTO_SH_DIRECT_WIN32(addr)
#define JMPTO_SH_LINUX(addr)
#define JMPTO_SH_DIRECT_LINUX(addr)
#endif
#if !defined( BREAKTHROUGH ) && !defined( BT )
#define JMPTO_BT_WIN32(addr)
#define JMPTO_BT_DIRECT_WIN32(addr)
#define JMPTO_BT_LINUX(addr)
#define JMPTO_BT_DIRECT_LINUX(addr)
#endif
#if defined ( WIN32 )
#if defined( GAME_DLL )
#define MP_NUMBER( gamex86, fgameded, cgamex86 ) gamex86
#define MP_STRING( gamex86, fgameded, cgamex86 ) gamex86
#define CALL_WIN32(addr) CALL(addr)
#define JMPTO_WIN32(addr) JMPTO(addr)
#define JMPTO_DIRECT_WIN32(addr) JMPTO_DIRECT(addr)
#if defined( SPEARHEAD ) || defined( SH )
#define JMPTO_SH_WIN32(addr) JMPTO(addr)
#define JMPTO_SH_DIRECT_WIN32(addr) JMPTO_DIRECT(addr)
#endif
#if defined( BREAKTHROUGH ) || defined( BT )
#define JMPTO_BT_WIN32(addr) JMPTO(addr)
#define JMPTO_BT_DIRECT_WIN32(addr) JMPTO_DIRECT(addr)
#endif
#else
#define CALL_WIN32(addr)
#define JMPTO_WIN32(addr)
#define JMPTO_DIRECT_WIN32(addr)
#define JMPTO_SH_WIN32(addr)
#define JMPTO_SH_DIRECT_WIN32(addr)
#define JMPTO_BT_WIN32(addr)
#define JMPTO_BT_DIRECT_WIN32(addr)
#endif
#define JMPTO_LINUX(addr)
#define JMPTO_DIRECT_LINUX(addr)
#define JMPTO_SH_LINUX(addr)
#define JMPTO_SH_DIRECT_LINUX(addr)
#define JMPTO_BT_LINUX(addr)
#define JMPTO_BT_DIRECT_LINUX(addr)
#define CALL_LINUX(addr)
#define SET_CLASS_LINUX( addr )
#define SET_CLASS_WIN32( addr ) SET_CLASS( addr )
#else
#define MP_NUMBER( gamex86, fgameded, cgamex86 ) fgameded
#define MP_STRING( gamex86, fgameded, cgamex86 ) fgameded
#define JMPTO_CLIENT(addr)
#define JMPTO_LINUX(addr) JMPTO(addr)
#define JMPTO_WIN32(addr)
#define JMPTO_DIRECT_CLIENT(addr)
#define JMPTO_DIRECT_LINUX(addr) JMPTO_DIRECT(addr)
#define JMPTO_DIRECT_WIN32(addr)
#if defined( SPEARHEAD ) || defined( SH )
#define JMPTO_SH_LINUX(addr) JMPTO(addr)
#define JMPTO_SH_DIRECT_LINUX(addr) JMPTO_DIRECT(addr)
#endif
#if defined( BREAKTHROUGH ) || defined( BT )
#define JMPTO_BT_LINUX(addr) JMPTO(addr)
#define JMPTO_BT_DIRECT_LINUX(addr) JMPTO_DIRECT(addr)
#endif
#define CALL_LINUX(addr) CALL(addr)
#define CALL_WIN32(addr)
#define SET_CLASS_LINUX( addr ) SET_CLASS( addr )
#define SET_CLASS_WIN32( addr )
#endif
#define MP_CODE( gamex86, fgameded, cgamex86 ) MP_NUMBER( gamex86, fgameded, cgamex86 )
#ifndef WIN32
extern void* dl_fgame_sym( const char *symbol );
#define SYMBOL_DECLARE( symbol ) DWORD _##symbol##_ = (DWORD)dl_fgame_sym( #symbol ) //void* symbol = dlsym( hmod, #symbol )
#define SYMBOL_GET( symbol ) _##symbol##_
#else
#define SYMBOL_DECLARE( symbol )
#define SYMBOL_GET( symbol ) 0
#endif
#define SYM( symbol ) SYMBOL_GET( symbol )
#endif /* __ASM_H__ */
-294
View File
@@ -1,294 +0,0 @@
#include "glb_local.h"
#include "cg_servercmds.h"
#include "cg_viewmodelanim.h"
#include "listener.h"
#include <Windows.h>
void CG_HookCGM()
{
BYTE jmp_code01[] = {
0xBA,
0x99,0x99,0x99,0x99,0xFF,0xE2
};
/*BYTE jmp_code01[] = {
0xE9,
0x4E,0x04,0x00,0x00
};
BYTE jmp_code02[] = {
0xE9,
0x44,0x05,0x00,0x00
};
BYTE jmp_code03[] = {
0xE9,
0xF2,0x03,0x00,0x00
};
BYTE jmp_code04[] = {
0xE9,
0x71,0x01,0x00,0x00
};
BYTE jmp_code05[] = {
0xE9,
0x33,0x0F,0x00,0x00
};
BYTE jmp_code06[] = {
0xE9,
0x2A,0x05,0x00,0x00
};
BYTE jmp_code07[] = {
0xE9,
0x26,0x00,0x00,0x00
};
BYTE jmp_code08[] = {
0xE9,
0x21,0x01,0x00,0x00
};*/
//test
*( DWORD * )( ( BYTE * )jmp_code01 + 1 ) = 0x30031346;
WriteMemory( 0x30030E5D, jmp_code01, sizeof( jmp_code01 ) );
WriteMemory( 0x30030EFC, jmp_code01, sizeof( jmp_code01 ) );
WriteMemory( 0x30030F4F, jmp_code01, sizeof( jmp_code01 ) );
WriteMemory( 0x30030FD0, jmp_code01, sizeof( jmp_code01 ) );
WriteMemory( 0x30031002, jmp_code01, sizeof( jmp_code01 ) );
WriteMemory( 0x3003109C, jmp_code01, sizeof( jmp_code01 ) );
WriteMemory( 0x300310DB, jmp_code01, sizeof( jmp_code01 ) );
WriteMemory( 0x30031135, jmp_code01, sizeof( jmp_code01 ) );
}
VOID CG_HookClientGame()
{
int i;
/* thunk_code1
* mov edx, 99999999h
* mov eax, [esp+24h+4]
* mov ebp, ecx
*
* push eax
* call edx
*/
/*BYTE thunk_code[250] = { 0xBA,
0x99,0x99,0x99,0x99,0xFF,0xD2,0x89,0x45,
0xB0
};*/
BYTE thunk_code[] = {
0xBA,
0x99,0x99,0x99,0x99,0xFF,0xE2,
};
/* thunk_code2
* mov edx, 99999999h
* call edx
*/
BYTE thunk_code2[] = { 0xBA,
0x99,0x99,0x99,0x99,0xFF,0xD2,0x90,0x90,
0x90,0x90,0x90,0x90,0x90,0x90
};
/* thunk_code3
* mov ecx, [99999999h+eax*4]
* push ecx
*/
BYTE thunk_code3[] = { 0x99,
0x99,0x99,0x99
};
/* thunk_code4
* mov edx, 99999999h
* push eax
* call edx
*/
BYTE thunk_code4[] = { 0xBA,
0x99,0x99,0x99,0x99,0x50,0xFF,0xD2,0xC9,
0xC3
};
/* thunk_code5
* mov edx, 99999999h
* call edx
*/
BYTE thunk_code5[] = { 0xBA,
0x99,0x99,0x99,0x99,0xFF,0xD2,0x90
};
/* thunk_code6
* mov edx, 99999999h
* call edx
* leave
* retn
*/
/*BYTE thunk_code6[] = { 0xBA,
0x99,0x99,0x99,0x99,0xFF,0xD2,0x5D,0xC3
};*/
BYTE thunk_code6[] = {
0xBA,
0x99,0x99,0x99,0x99,0xFF,0xE2,
};
/* thunk_code7
* push 303EBF2Ch ; offset unk_303EBF2C
* push 303EBFD0h ; offset dword_303EBFD0
* mov edx, 3005C83Ch
* call edx
* add esp, 8
*
* push 0
* lea edx, [ebp-198h] ; [ebp+Dst]
* push edx
* mov eax, 300473F0h
* call eax ; CG_OffsetFirstPersonView
* add esp, 8
*/
/*BYTE thunk_code7[65] = { 0x68,
0x2C,0xBF,0x3E,0x30,0x68,0xD0,0xBF,0x3E,
0x30,0xBA,0x3C,0xC8,0x05,0x30,0xFF,0xD2,
0x81,0xC4,0x08,0x00,0x00,0x00,0x68,0x00,
0x00,0x00,0x00,0x8D,0x95,0x68,0xFE,0xFF,
0xFF,0x52,0xB8,0xF0,0x73,0x04,0x30,0xFF,
0xD0,0x81,0xC4,0x08,0x00,0x00,0x00
};*/
BYTE thunk_code7[6];
/* thunk_code8
* cmp [ebp+var_28], 2
*/
BYTE thunk_code8[4] = { 0x83,
0x7D,0xD8,0x02
};
BYTE thunk_code9[4];
BYTE thunk_code10[15];
BYTE thunk_code11[60];
BYTE thunk_code12[] = {
0xBA,
0x99,0x99,0x99,0x99,0xFF,0xB5,0xC4,0xFC,
0xFF,0xFF,0xFF,0xD2
};
/*BYTE thunk_code13[] = {
0xBA,
0x99,0x99,0x99,0x99,0xFF,0xB5,0x70,0xFE,
0xFF,0xFF,0xFF,0xD2,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90
};*/
BYTE thunk_code13[] = {
0x90,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x90,0x90,0x90,0x90,0x90
};
BYTE thunk_code14[] = {
0xBA,
0x99,0x99,0x99,0x99,0xFF,0xE2
};
BYTE thunk_code15[] = {
0x31,
0xC0, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
0x90, 0x90, 0x90, 0x90, 0x90
};
BYTE thunk_code16[] = {
0x90,
0x90
};
BYTE thunk_code17[] = {
0xEB,
0x2B
};
//for(i=10;i<250;i++)
// thunk_code[i] = 0x90; // NOP instructions
/*for(i=13;i<sizeof(thunk_code13);i++)
thunk_code13[i] = 0x90;*/
memset(thunk_code7, 0x90, sizeof(thunk_code7));
*(DWORD*)((BYTE*)thunk_code + 1) = (DWORD)CG_ViewModelAnimCheck;
*(DWORD*)((BYTE*)thunk_code2 + 1) = (DWORD)CG_ServerCommand;
*(DWORD*)((BYTE*)thunk_code3) = (DWORD)itemPrefix;
*(DWORD*)((BYTE*)thunk_code4 + 1) = (DWORD)VM_GetVMAnimPrefixString;
*(DWORD*)((BYTE*)thunk_code5 + 1) = (DWORD)CG_GetViewModelAnimName;
*(DWORD*)((BYTE*)thunk_code6 + 1) = (DWORD)CG_HeightCheck;
//*(DWORD*)((BYTE*)thunk_code12 + 1) = (DWORD)CG_ParseCGMessage;
//*(DWORD*)((BYTE*)thunk_code13 + 1) = (DWORD)CG_CalcViewBob;
//*(DWORD*)((BYTE*)thunk_code14 + 1) = (DWORD)CG_Command_ProcessFile;
//ReplaceInstruction((LPVOID)0x3004999D, thunk_code, sizeof(thunk_code));
WriteMemory(0x30049763, thunk_code, sizeof(thunk_code));
WriteMemory(0x30033419, thunk_code2, sizeof(thunk_code2));
WriteMemory(0x3004985F, thunk_code3, sizeof(thunk_code3));
WriteMemory(0x30049AA1, thunk_code3, sizeof(thunk_code3));
WriteMemory(0x300494EF, thunk_code4, sizeof(thunk_code4));
WriteMemory(0x30049AAF, thunk_code5, sizeof(thunk_code5));
//WriteMemory(0x30003966, thunk_code6, sizeof(thunk_code6));
WriteMemory(0x30031346, thunk_code12, sizeof(thunk_code12));
WriteMemory(0x30047B91, thunk_code13, sizeof(thunk_code13));
CG_ModelAnim_f = ( DWORD )detour_function( ( PBYTE )0x3002AE9C, ( PBYTE )CG_ModelAnim, 9 );
CG_OffsetFirstPersonView_f = ( DWORD )detour_function( ( PBYTE )0x300473F0, ( PBYTE )CG_OffsetFirstPersonView, 9 );
CG_OffsetThirdPersonView_f = ( DWORD )detour_function( ( PBYTE )0x30048E49, ( PBYTE )CG_OffsetThirdPersonView, 9 );
//ReplaceInstruction((LPVOID)0x3001A6C9, thunk_code14, sizeof(thunk_code14));
/* Patch CG_ModelAnim so that the fps doesn't get ugly when cg_animationviewmodel is
* set to 1
*/
WriteMemory(0x3002CB36, thunk_code7, sizeof(thunk_code7));
/* Patch the z value of the fps so that we can set it to a custom one */
WriteMemory(0x3004A279, thunk_code8, sizeof(thunk_code8));
//*(DWORD*)((BYTE*)thunk_code9) = (DWORD)&internal_bobOffset;
//ReplaceInstruction((LPVOID)0x30047BA5, thunk_code9, sizeof(thunk_code9));
/* If a player is playing a demo/has physics off, then the view shouldn't
* be sync with the server
*/
memset(thunk_code10, 0x90, sizeof(thunk_code10));
//memset(thunk_code11, 0x90, sizeof(thunk_code11));
/*WriteMemory(0x30031DDF, thunk_code10, sizeof(thunk_code10));*/
//WriteMemory( 0x300567AB, thunk_code15, sizeof( thunk_code15 ) );
// Patch the event system so that events with the same name will count
WriteMemory( 0x300567C0, thunk_code16, sizeof( thunk_code16 ) );
WriteMemory( 0x00469F2C, thunk_code17, sizeof( thunk_code17 ) );
//Event::LoadEvents_f = ( LoadEvents_o )detour_function( ( void * )0x300528FE, &Event::LoadEvents, 10 );
/* FIXME: if g_synchronousClients/cg_nopredict is enabled, then the view
* bobbing and the move animation must still be enabled too
*/
//ReplaceInstruction((LPVOID)0x300205ED, thunk_code11, sizeof(thunk_code11));
}
-6
View File
@@ -1,6 +0,0 @@
#ifndef __HOOK_H__
#define __HOOK_H__
void CG_HookClientGame();
#endif
-648
View File
@@ -1,648 +0,0 @@
#include "glb_local.h"
#include "cg_hud.h"
#include <iostream>
#include <fstream>
#include <string>
//Stuff for menu credit to okidoki
uidef_t *uid;
qkey_t *keys;
qboolean *inGuiMouse = ( qboolean * )0x12F6FF8;
// ***fonts***
fontHeader_t *facfont20 = NULL;
fontHeader_t *courier16 = NULL;
fontHeader_t *courier18 = NULL;
fontHeader_t *courier20 = NULL;
fontHeader_t *handle16 = NULL;
fontHeader_t *handle18 = NULL;
fontHeader_t *marlett = NULL;
fontHeader_t *verdana12 = NULL;
fontHeader_t *verdana14 = NULL;
/*Cvars*/
cvar_t *stats;
cvar_t *menu;
//Stat Variables
int headshots;
int killingspree;
int unstoppable;
int rampage;
int godlike;
int kills;
int bashes;
int dominating;
int double_kill_time;
int gotdouble;
int doublekill;
int multikill;
int ultrakill;
int monsterkill;
float hintAlpha = 1.0f;
int hintAlphaTime = 0;
qboolean hintClear = false;
char hintString[ MAX_STRING_TOKENS ];
// colors
vec4_t colorDkRed = {0.5, 0, 0, 1};
vec4_t colorDkGreen = {0, 0.5, 0, 1};
vec4_t colorDkBlue = {0, 0, 0.5, 1};
vec4_t colorLtRed = {1, 0.5, 0.5, 1};
vec4_t colorLtGreen = {0.5, 1, 0.5, 1};
vec4_t colorLtBlue = {0.5, 0.5, 1, 1};
vec4_t colorAlBlue = {0, 0, 1, 0.25};
vec4_t colorAlRed = {1, 0, 0, 0.25};
vec4_t colorLtzzTEST = {1, 1, 1, 0.25};
vec4_t alphaLight = { 0, 0, 0, 0.25 };
vec4_t alphaMid = { 0, 0, 0, 0.5 };
vec4_t alphaDark = { 0, 0, 0, 0.75 };
vec4_t colorTransRed = { 1, 0, 0, 0.5 };
vec4_t colorTransBlue = { 0, 0, 1, 0.5 };
vec4_t colorTransWhite = { 1, 1, 1, 0.5 };
vec4_t colorDarkRed = { 0.34117647058823529411764705882353f, 0.035294117647058823529411764705882f, 0.035294117647058823529411764705882f, 1 };
hdExtend_t *huddrawExtends;
void CG_DrawMenu()
{
time_t rawtime;
struct tm * timeinfo = (tm * )malloc(sizeof(tm));
time( &rawtime );
localtime_s( timeinfo, &rawtime);
char buff[64];
/*Draw the menu*/
if(menu->integer)
{
//Enable the mouse
*inGuiMouse = uid->uiHasMouse = true;
//Get Cursor coordinates
uid->mouseX;
uid->mouseY;
/*Widgets*/
//We want to make a few selections(widgets)
//-------------First Widget---------------------
cgi.R_SetColor( colorWhite ); //outer outline will be white
cgi.R_DrawBox(10, 160, 101, 16);
cgi.R_SetColor( colorDarkRed ); //inner red box
cgi.R_DrawBox(11, 161, 99, 14);
cgi.R_SetColor( colorWhite ); //font color
sprintf_s( buff, "First Widget");//name of widget
cgi.R_DrawString( verdana12, buff, 12, 161, -1, 0 );
//-------------Second Widget---------------------
cgi.R_SetColor( colorWhite ); //outer outline will be white
cgi.R_DrawBox(10, 180, 101, 16);
cgi.R_SetColor( colorDarkRed ); //inner red box
cgi.R_DrawBox(11, 181, 99, 14);
cgi.R_SetColor( colorWhite ); //font color
sprintf_s( buff, "Second Widget");//name of widget
cgi.R_DrawString( verdana12, buff, 12, 181, -1, 0 );
//-------------Third Widget---------------------
cgi.R_SetColor( colorWhite ); //outer outline will be white
cgi.R_DrawBox(10, 200, 101, 16);
cgi.R_SetColor( colorDarkRed ); //inner red box
cgi.R_DrawBox(11, 201, 99, 14);
cgi.R_SetColor( colorWhite ); //font color
sprintf_s( buff, "Third Widget");//name of widget
cgi.R_DrawString( verdana12, buff, 12, 201, -1, 0 );
//-------------Fourth Widget---------------------
cgi.R_SetColor( colorWhite ); //outer outline will be white
cgi.R_DrawBox(10, 220, 101, 16);
cgi.R_SetColor( colorDarkRed ); //inner red box
cgi.R_DrawBox(11, 221, 99, 14);
cgi.R_SetColor( colorWhite ); //font color
sprintf_s( buff, "Fourth Widget");//name of widget
cgi.R_DrawString( verdana12, buff, 12, 221, -1, 0 );
//Check if it was clicked
if(keys[181].down)
{
if((uid->mouseX >= 11)&&(uid->mouseX <= 110)&&(uid->mouseY >= 161)&&(uid->mouseY <= 175))
{
cgi.R_SetColor( colorWhite ); //font color
sprintf_s( buff, (const char *)cg->snap->ps.stats);//name of widget
cgi.R_DrawString( verdana12, buff, 12, 300, -1, 0 );
cgi.Printf("I clicked the first widget \n");
}
if((uid->mouseX >= 11)&&(uid->mouseX <= 110)&&(uid->mouseY >= 181)&&(uid->mouseY <= 195))
cgi.Printf("I clicked the second widget \n");
if((uid->mouseX >= 11)&&(uid->mouseX <= 110)&&(uid->mouseY >= 201)&&(uid->mouseY <= 215))
cgi.Printf("I clicked the third widget \n");
if((uid->mouseX >= 11)&&(uid->mouseX <= 110)&&(uid->mouseY >= 211)&&(uid->mouseY <= 235))
cgi.Printf("I clicked the fourth widget \n");
}
//-------------Time---------------------
if(timeinfo->tm_hour == 00)
{
cgi.R_SetColor( colorWhite );
sprintf_s( buff, "%02i:%02i:%02i AM", timeinfo->tm_hour + 12, timeinfo->tm_min, timeinfo->tm_sec);
cgi.R_DrawString( verdana12, buff, 12, 241, 10, 0 );
}
else if(timeinfo->tm_hour > 13)
{
cgi.R_SetColor( colorWhite );
sprintf_s( buff, "%i:%02i:%02i PM", ((timeinfo->tm_hour)%12), timeinfo->tm_min, timeinfo->tm_sec);
cgi.R_DrawString( verdana12, buff, 12, 241, 10, 0 );
}
else if(timeinfo->tm_hour > 00 && timeinfo->tm_hour < 13)
{
cgi.R_SetColor( colorWhite );
sprintf_s( buff, "%i:%02i:%02i AM", ((timeinfo->tm_hour)%12), timeinfo->tm_min, timeinfo->tm_sec);
cgi.R_DrawString( verdana12, buff, 12, 241, 10, 0 );
}
cgi.R_SetColor( NULL );
}
}
qboolean CG_WorldToScreen(vec3_t pt, int *x, int *y, qboolean bOptionalSeen, int shader_width, int shader_height)
{
float xzi, yzi;
vec3_t local, transformed;
vec3_t vfwd, vright, vup;
qboolean bNotShown = false;
AngleVectors(cg->refdefViewAngles, vfwd, vright, vup);
VectorSubtract(pt, cg->refdef.viewOrg, local);
transformed[0] = DotProduct( local, vright );
transformed[1] = DotProduct( local, vup );
transformed[2] = DotProduct( local, vfwd );
if(transformed[2] < 0.01f)
{
if(!bOptionalSeen)
return false;
bNotShown = true;
//transformed[0] = -transformed[0];
//transformed[1] = -transformed[1];
//return qfalse;
}
int centerX = (cgs->glConfig.vidWidth / 2);
int centerY = (cgs->glConfig.vidHeight / 2);
xzi = centerX / transformed[2] * ( 90.0f / cg->refdef.fovX );
yzi = centerY / transformed[2] * ( 90.0f / cg->refdef.fovY );
*x = centerX + (int)( xzi * transformed[0] );
*y = centerY - (int)( yzi * transformed[1] );
if(!bOptionalSeen)
return true;
int limitX = cgs->glConfig.vidWidth - shader_width;
int limitY = cgs->glConfig.vidHeight - shader_height;
if(bNotShown)
{
if(*x < limitX)
*x = limitX;
else if(*x > 0)
*x = 0;
else if(*y < limitY)
*y = limitY;
else if(*y > 0)
*y = 0;
}
if(*x > limitX)
*x = limitX;
else if(*x < 0)
*x = 0;
if(*y > limitY)
*y = limitY;
else if(*y < 0)
*y = 0;
return true;
}
#if 0
void CG_Draw3DIcon(hdExtend_t * hdex, hdElement_t * hde)
{
int x, y;
centity_t * ce;
int width, height;
/* Reset if huddraw_rect has been called */
if(hdex->h3d.x != hde->x || hdex->h3d.y != hde->y)
{
memset(&hdex->h3d, 0, sizeof(hdex->h3d));
return;
}
if(hdex->h3d.ent_num != -1)
ce = CG_GetEntity(hdex->h3d.ent_num);
else
ce = NULL;
if(ce != NULL)
VectorAdd(hdex->h3d.vector, ce->currentState.origin, hdex->h3d.currentOrg);
//else
// VectorCopy(hdex->h3d.vector, hdex->h3d.currentOrg);
if(hde->shader)
{
width = cgi.R_GetShaderWidth(hde->shader);
height = cgi.R_GetShaderWidth(hde->shader);
}
else
{
width = hde->width;
height = hde->height;
}
if(!CG_WorldToScreen(hdex->h3d.currentOrg, &x, &y, hdex->h3d.bAlwaysShow, width, height))
return;
hde->horizontalAlign = 0;
hde->verticalAlign = 0;
hde->virtualScreen = 0;
hde->x = x;
hde->y = y;
hdex->h3d.x = x;
hdex->h3d.y = y;
}
void CG_DrawTimers(hdExtend_t * hdex, hdElement_t * hde)
{
int minutes;
float seconds;
char *string;
if( !hdex->timer.bEnabled || hdex->timer.current <= 0.0f ) {
return;
}
hdex->timer.current -= 0.001000000047497451f * cg_frametime;
if(hdex->timer.current <= 0.0f)
{
if(hdex->timer.fade_out_time >= 0.0f)
{
hde->color[3] = 0.0f;
hdex->timer.alpha = 0.0f;
}
hdex->timer.current = 0.0f;
}
if(hdex->timer.current >= 60.00000000f)
{
seconds = (float)((int)hdex->timer.current % 60);
minutes = (int)(hdex->timer.current / 60.0f);
}
else
{
if(hdex->timer.current >= 30.0f)
seconds = (float)(int)hdex->timer.current;
else
seconds = hdex->timer.current;
minutes = 0;
}
if(hdex->timer.current >= 30.0f)
string = "%d:%02.0f";
else
{
if(hdex->timer.current >= 10.0f)
string = "%d:%02.1f";
else
string = "%d:0%.1f";
}
if(hdex->timer.current * 1000.0f < hdex->timer.fade_out_time)
{
hde->color[3] -= (2.0f-hdex->timer.alpha)/hdex->timer.fade_out_time * cg_frametime;
if(hde->color[3] < 0.0f)
hde->color[3] = 0.0f;
}
else
hdex->timer.alpha = hde->color[3];
if(!hde->shader)
{
if(_strcmpi(hde->string, hdex->timer.string) == 0)
{
sprintf(hde->string, string, minutes, seconds);
strcpy(hdex->timer.string, hde->string);
}
}
else
memset(hde->string, 0, MAX_STRINGCHARS);
}
void CG_DrawExtendedHud()
{
int i;
hdExtend_t *hdex;
hdElement_t *hde;
if( hintString[0] != '\0' )
{
int key1 = 0, key2 = 0;
const char *keyname1, *keyname2;
char *hintStringFormatted;
char *hintStringKey;
char *hintStringPart;
int i, old_c;
if( !facfont20 ) {
return;
}
// Fade out the string over time
if( hintClear )
{
if( hintAlpha > 0.0f )
{
float ratio = hintAlphaTime/100.0f;
hintAlphaTime += cg->frametime;
if( ratio >= 1.0f ) {
hintAlpha = 0.0f;
} else {
hintAlpha = 1.0f + ( 0.0f - 1.0f ) * ratio;
}
}
else
{
hintAlpha = 0.0f;
hintAlphaTime = 0;
hintClear = false;
memset( hintString, '\0', strlen( hintString ) );
}
} else {
hintAlpha = 1.0f;
}
cgi.Key_GetKeysForCommand( "+use", &key1, &key2 );
keyname1 = uppercase( cgi.LV_ConvertString ( cgi.Key_KeynumToBindString( key1 ) ) );
keyname2 = uppercase( cgi.LV_ConvertString ( cgi.Key_KeynumToBindString( key2 ) ) );
// Format the hint string
hintStringFormatted = replace( hintString, "&&1", "\t&&1" );
hintStringFormatted = replace( hintStringFormatted, "&&1", keyname1 );
char *hintStringLocalized = cgi.LV_ConvertString( hintStringFormatted );
int w = re.GetFontStringWidth( facfont20, hintStringLocalized ) - 10;
for( i = 0; i < strlen( hintStringLocalized ); i++ )
{
if( hintStringLocalized[ i ] == '\t' )
{
hintStringLocalized[ i ] = '\0';
break;
}
}
int x = ( cgs->glConfig.vidWidth - w ) / 2;
int y = cgs->glConfig.vidHeight / 1.75;
vec4_t rgba = { 1, 1, 1, hintAlpha };
cgi.R_SetColor( rgba );
cgi.R_DrawString( facfont20, hintStringLocalized, x, y, MAX_STRINGTOKENS, false );
x += re.GetFontStringWidth( facfont20, hintStringLocalized );
hintStringKey = hintStringLocalized + i + 1;
// yellow
rgba[0] = 1.0f;
rgba[1] = 1.0f;
rgba[2] = 0.0f;
rgba[3] = hintAlpha;
int len = strlen( keyname1 );
old_c = hintStringKey[ len ];
hintStringKey[ len ] = '\0';
cgi.R_SetColor( rgba );
cgi.R_DrawString( facfont20, hintStringKey, x, y, MAX_STRINGTOKENS, false );
hintStringKey[ len ] = old_c;
x += re.GetFontStringWidth( facfont20, keyname1 );
hintStringPart = hintStringKey + len;
rgba[0] = 1.0f;
rgba[1] = 1.0f;
rgba[2] = 1.0f;
rgba[3] = hintAlpha;
cgi.R_SetColor( rgba );
cgi.R_DrawString( facfont20, hintStringPart, x, y, MAX_STRINGTOKENS, false );
}
for( i = 0; i < 256; i++ )
{
hde = cgi.hudDrawElements + i;
hdex = huddrawExtends + i;
if( hdex->h3d.bEnabled ) {
CG_Draw3DIcon( hdex, hde );
}
if( hdex->timer.bEnabled ) {
CG_DrawTimers( hdex, hde );
}
}
}
#endif
void CG_DrawHintString()
{
if( hintString[0] != '\0' )
{
int key1 = 0, key2 = 0;
str keyname1, keyname2;
char *hintStringFormatted;
char *hintStringKey;
char *hintStringPart;
int i, old_c;
if( !facfont20 ) {
return;
}
// Fade out the string over time
if( hintClear )
{
if( hintAlpha > 0.0f )
{
float ratio = hintAlphaTime/100.0f;
hintAlphaTime += cg->frametime;
if( ratio >= 1.0f ) {
hintAlpha = 0.0f;
} else {
hintAlpha = 1.0f + ( 0.0f - 1.0f ) * ratio;
}
}
else
{
hintAlpha = 0.0f;
hintAlphaTime = 0;
hintClear = false;
memset( hintString, '\0', strlen( hintString ) );
}
} else {
hintAlpha = 1.0f;
}
cgi.Key_GetKeysForCommand( "+use", &key1, &key2 );
keyname1 = cgi.LV_ConvertString( cgi.Key_KeynumToBindString( key1 ) );
keyname2 = cgi.LV_ConvertString( cgi.Key_KeynumToBindString( key2 ) );
keyname1.toupper();
keyname2.toupper();
// Format the hint string
hintStringFormatted = replace( hintString, "&&1", "\t&&1" );
hintStringFormatted = replace( hintStringFormatted, "&&1", keyname1 );
char *hintStringLocalized = cgi.LV_ConvertString( hintStringFormatted );
float w = re.GetFontStringWidth( facfont20, hintStringLocalized ) - 10;
for( i = 0; i < strlen( hintStringLocalized ); i++ )
{
if( hintStringLocalized[ i ] == '\t' )
{
hintStringLocalized[ i ] = '\0';
break;
}
}
float x = ( cgs->glConfig.vidWidth - w ) / 2;
float y = cgs->glConfig.vidHeight / 1.75;
vec4_t rgba = { 1, 1, 1, hintAlpha };
cgi.R_SetColor( rgba );
cgi.R_DrawString( facfont20, hintStringLocalized, x, y, MAX_STRING_TOKENS, false );
x += re.GetFontStringWidth( facfont20, hintStringLocalized );
hintStringKey = hintStringLocalized + i + 1;
// yellow
rgba[0] = 1.0f;
rgba[1] = 1.0f;
rgba[2] = 0.0f;
rgba[3] = hintAlpha;
int len = strlen( keyname1 );
old_c = hintStringKey[ len ];
hintStringKey[ len ] = '\0';
cgi.R_SetColor( rgba );
cgi.R_DrawString( facfont20, hintStringKey, x, y, MAX_STRING_TOKENS, false );
hintStringKey[ len ] = old_c;
x += re.GetFontStringWidth( facfont20, keyname1 );
hintStringPart = hintStringKey + len;
rgba[0] = 1.0f;
rgba[1] = 1.0f;
rgba[2] = 1.0f;
rgba[3] = hintAlpha;
cgi.R_SetColor( rgba );
cgi.R_DrawString( facfont20, hintStringPart, x, y, MAX_STRING_TOKENS, false );
}
}
void CG_ShowHint( const char * hint )
{
if( hint == NULL || strlen( hint ) <= 0 || _stricmp( hint, "" ) == 0 || hint[0] == '\0' )
{
hintAlphaTime = 0;
hintClear = true;
return;
}
hintClear = false;
strcpy( hintString, hint );
}
void CG_Draw2D(void)
{
// CG_DrawStats();
// CG_DrawMenu();
// CG_DrawExtendedHud();
if( facfont20 == NULL ) {
facfont20 = cgi.R_LoadFont( "facfont-20" );
}
if( courier16 == NULL ) {
courier16 = cgi.R_LoadFont( "courier-16" );
}
if( courier18 == NULL ) {
courier18 = cgi.R_LoadFont( "courier-18" );
}
if( courier20 == NULL ) {
courier20 = cgi.R_LoadFont( "courier-20" );
}
if( handle16 == NULL ) {
handle16 = cgi.R_LoadFont( "handle-16" );
}
if( handle18 == NULL ) {
handle18 = cgi.R_LoadFont( "handle-18" );
}
if( marlett == NULL ) {
marlett = cgi.R_LoadFont( "marlett" );
}
if( verdana12 == NULL ) {
verdana12 = cgi.R_LoadFont( "verdana-12" );
}
if( verdana14 == NULL ) {
verdana14 = cgi.R_LoadFont( "verdana-14" );
}
CG_DrawHintString();
// huddraw elements have the lowest priority
Hud::ProcessThink();
vec4_t col = { 1.f, 1.f, 1.f, 1.f };
cgi.R_SetColor( col );
cge.CG_Draw2D();
}
-65
View File
@@ -1,65 +0,0 @@
#ifndef __CG_HUD_H__
#define __CG_HUD_H__
#include "hud.h"
#ifdef __cplusplus
extern "C" {
#endif
extern cvar_t *stats;
extern cvar_t *menu;
extern uidef_t *uid;
extern qkey_t *keys;
extern fontHeader_t *facfont20;
extern fontHeader_t *courier16;
extern fontHeader_t *courier18;
extern fontHeader_t *courier20;
extern fontHeader_t *handle16;
extern fontHeader_t *handle18;
extern fontHeader_t *marlett;
extern fontHeader_t *verdana12;
extern fontHeader_t *verdana14;
void CG_Draw2D();
void CG_ShowHint( const char * hint );
typedef struct hdTimer_s
{
qboolean bEnabled;
float duration;
float current;
float fade_out_time;
float alpha;
char string[ MAX_STRING_CHARS ];
} hdTimer_t;
typedef struct hd3d_s
{
qboolean bEnabled;
qboolean bAlwaysShow;
qboolean bDepth;
vec3_t vector;
int ent_num;
vec3_t currentOrg;
int x, y;
} hd3d_t;
typedef struct hdExtend_s
{
struct hdTimer_s timer;
struct hd3d_s h3d;
} hdExtend_t;
extern hdExtend_t *huddrawExtends;
#ifdef __cplusplus
}
#endif
#endif
-872
View File
@@ -1,872 +0,0 @@
#include "glb_local.h"
#include "script/clientgamecommand.h"
#include "cg_hud.h"
#include "cg_viewmodelanim.h"
#include "script/cplayer.h"
#include "scriptvariable.h"
#include "scriptmaster.h"
#define MAX_IMPACTS 64
// wall impacts
static vec3_t *wall_impact_pos = ( vec3_t * )0x302659E8;
static vec3_t *wall_impact_norm = ( vec3_t * )0x30265CE8;
static int *wall_impact_large = ( int * )0x302655E8;
static int *wall_impact_type = ( int * )0x30266568;
static int *wall_impact_count = ( int * )0x30269A74;
// flesh impacts
static vec3_t *flesh_impact_pos = ( vec3_t * )0x302656E8;
static vec3_t *flesh_impact_norm = ( vec3_t * )0x30266768;
static int *flesh_impact_large = ( int * )0x30266668;
static int *flesh_impact_count = ( int * )0x30269A78;
static int *current_entity_number = ( int * )0x3007C68C;
typedef void ( *CG_MakeBulletTracer_f )( float *i_vBarrel, float *i_vStart,
float (*i_vEnd)[3], int i_iNumBullets, qboolean iLarge,
int iTracerVisible, qboolean bIgnoreEntities );
CG_MakeBulletTracer_f CG_MakeBulletTracer = ( CG_MakeBulletTracer_f )0x300313F6;
typedef void ( *CG_MakeBubbleTrail_f )( float *i_vStart, float *i_vEnd, int iLarge );
CG_MakeBubbleTrail_f CG_MakeBubbleTrail = ( CG_MakeBubbleTrail_f )0x3002E233;
typedef void ( *CG_MeleeImpact_f )( float *vStart, float *vEnd );
CG_MeleeImpact_f CG_MeleeImpact = ( CG_MeleeImpact_f )0x30035AD4;
typedef void ( *CG_MakeExplosionEffect_f )( float *vPos, int iType );
CG_MakeExplosionEffect_f CG_MakeExplosionEffect = ( CG_MakeExplosionEffect_f )0x3002FD7B;
typedef void ( *CG_SpawnEffectModel_f )( const char *model, vec3_t origin, vec3_t axis[3] );
CG_SpawnEffectModel_f CG_SpawnEffectModel = ( CG_SpawnEffectModel_f )0x302A52E8;
int ReadNumber()
{
if( reborn ) {
return cgi.MSG_ReadShort();
} else {
return cgi.MSG_ReadByte();
}
}
void CG_ParseCGMessage2() {
int msgtype;
vec3_t vecStart, vecTmp, vecEnd, vecArray[64];
vec3_t axis[3];
int iCount, iLarge;
int i, iTemp;
const char *s;
qboolean loop;
hdElement_t *hde;
int index;
const char *name;
Hud *hud;
float col_x, col_y, col_z;
const char *weapname, *prefix;
const char *hint;
qboolean bFullAnim;
float alpha;
float time, fade_at_time;
float rate;
qboolean time_up;
short width, height;
float speed;
float volume;
Vector vector_or_offset;
short ent_num;
qboolean always_show;
qboolean has_depth;
do {
msgtype = cgi.MSG_ReadBits( 6 );
//if(cg_debugCGMessages.integer) {
// Com_Printf( "CG_ParseCGMessage: command type %i\n", msgtype );
//}
switch ( msgtype ) {
case 1: // BulletTracer (visible?)
vecTmp[0] = cgi.MSG_ReadCoord();
vecTmp[1] = cgi.MSG_ReadCoord();
vecTmp[2] = cgi.MSG_ReadCoord();
case 2: // BulletTracer (invisible?)
case 5: // BubbleTrail
vecStart[0] = cgi.MSG_ReadCoord();
vecStart[1] = cgi.MSG_ReadCoord();
vecStart[2] = cgi.MSG_ReadCoord();
if ( msgtype != 1 ) {
vecTmp[0] = vecStart[0];
vecTmp[1] = vecStart[1];
vecTmp[2] = vecStart[2];
}
vecArray[0][0] = cgi.MSG_ReadCoord();
vecArray[0][1] = cgi.MSG_ReadCoord();
vecArray[0][2] = cgi.MSG_ReadCoord();
iLarge = cgi.MSG_ReadBits( 1 );
if( msgtype==1 ) {
CG_MakeBulletTracer( vecTmp, vecStart, vecArray, 1, iLarge, 1, 1 );
} else if( msgtype==2 ) {
CG_MakeBulletTracer( vecTmp, vecStart, vecArray, 1, iLarge, 0, 1 );
} else {
CG_MakeBubbleTrail( vecStart, vecArray[0], iLarge );
}
break;
case 3: // BulletTracer multiple times
vecTmp[0] = cgi.MSG_ReadCoord();
vecTmp[1] = cgi.MSG_ReadCoord();
vecTmp[2] = cgi.MSG_ReadCoord();
iTemp = cgi.MSG_ReadBits( 6 );
case 4: // BulletTracer multiple times (shotgun shot)
if ( msgtype == 4 ) {
iTemp = 0;
}
vecStart[0] = cgi.MSG_ReadCoord();
vecStart[1] = cgi.MSG_ReadCoord();
vecStart[2] = cgi.MSG_ReadCoord();
iLarge = cgi.MSG_ReadBits( 1 );
iCount = cgi.MSG_ReadBits( 6 );
// this check is missing in MOHAA code, so this has buffer overflow risk in AA
if ( iCount > 64 ) {
cgi.Error( ERR_DROP, "CG message type 4 sent too many data.\n" );
}
for (i=0;i<iCount;i++) {
vecArray[i][0] = cgi.MSG_ReadCoord();
vecArray[i][1] = cgi.MSG_ReadCoord();
vecArray[i][2] = cgi.MSG_ReadCoord();
}
CG_MakeBulletTracer( vecTmp, vecStart, vecArray, iCount, iLarge, iTemp, 1 );
break;
case 6: // wall impact
case 7: // flesh impact
case 8: // flesh impact (?)
case 9: // wall impact (?)
case 10: // wall impact (?)
vecStart[0] = cgi.MSG_ReadCoord();
vecStart[1] = cgi.MSG_ReadCoord();
vecStart[2] = cgi.MSG_ReadCoord();
cgi.MSG_ReadDir( vecEnd );
iLarge = cgi.MSG_ReadBits( 1 );
switch ( msgtype ) {
case 6: // a window was hit
if( *wall_impact_count < MAX_IMPACTS ) {
VectorCopy( vecStart, wall_impact_pos[*wall_impact_count] );
VectorCopy( vecEnd, wall_impact_norm[*wall_impact_count] );
wall_impact_large[*wall_impact_count] = iLarge;
( *wall_impact_count )++;
}
break;
case 7:
if( *flesh_impact_count < MAX_IMPACTS ) {
// inverse hit normal, I dont know why,
// but that's done by MoHAA
VectorInverse( vecEnd );
VectorCopy( vecStart,flesh_impact_pos[*flesh_impact_count] );
VectorCopy( vecEnd,flesh_impact_norm[*flesh_impact_count] );
flesh_impact_large[*flesh_impact_count] = iLarge;
( *flesh_impact_count )++;
}
break;
case 8:
if( *flesh_impact_count < MAX_IMPACTS ) {
// same here?
VectorInverse( vecEnd );
VectorCopy( vecStart, flesh_impact_pos[*flesh_impact_count] );
VectorCopy( vecEnd, flesh_impact_norm[*flesh_impact_count] );
flesh_impact_large[*flesh_impact_count] = iLarge;
( *flesh_impact_count )++;
}
break;
case 9:
if( *wall_impact_count < MAX_IMPACTS ) {
VectorCopy( vecStart, wall_impact_pos[*wall_impact_count] );
VectorCopy( vecEnd, wall_impact_norm[*wall_impact_count] );
wall_impact_large[*wall_impact_count] = iLarge;
if(iLarge) {
wall_impact_type[*wall_impact_count] = 3;
} else {
wall_impact_type[*wall_impact_count] = 2;
}
( *wall_impact_count )++;
}
break;
case 10:
if( *wall_impact_count < MAX_IMPACTS ) {
VectorCopy( vecStart, wall_impact_pos[*wall_impact_count] );
VectorCopy( vecEnd, wall_impact_norm[*wall_impact_count] );
wall_impact_large[*wall_impact_count] = iLarge;
if(iLarge) {
wall_impact_type[*wall_impact_count] = 5;
} else {
wall_impact_type[*wall_impact_count] = 4;
}
( *wall_impact_count )++;
}
break;
default:
break;
}
break;
case 11:
vecStart[0] = cgi.MSG_ReadCoord();
vecStart[1] = cgi.MSG_ReadCoord();
vecStart[2] = cgi.MSG_ReadCoord();
vecEnd[0] = cgi.MSG_ReadCoord();
vecEnd[1] = cgi.MSG_ReadCoord();
vecEnd[2] = cgi.MSG_ReadCoord();
CG_MeleeImpact(vecStart,vecEnd);
break;
case 12: // m1 frag/stiel grenade explosion
case 13: // bazooka/panzershrek projectile explosion
vecStart[0] = cgi.MSG_ReadCoord();
vecStart[1] = cgi.MSG_ReadCoord();
vecStart[2] = cgi.MSG_ReadCoord();
CG_MakeExplosionEffect(vecStart,msgtype);
break;
default: //unknown message
cgi.Error( ERR_DROP, "CG_ParseCGMessage: Unknown CG Message %i", msgtype );
break;
case 14:
case 15: // MakeEffect
case 16:
case 17:
case 18:
case 19: // oil barrel effect
case 20:
case 21: // oil barrel effect top
case 22: // oil barrel effect top - first hit
vecStart[0] = cgi.MSG_ReadCoord();
vecStart[1] = cgi.MSG_ReadCoord();
vecStart[2] = cgi.MSG_ReadCoord();
cgi.MSG_ReadDir( vecEnd );
sfxManager->MakeEffect_Normal( msgtype + 67, vecStart, vecEnd );
break;
case 23: // broke crate
case 24: // broke glass window
vecStart[0] = cgi.MSG_ReadCoord();
vecStart[1] = cgi.MSG_ReadCoord();
vecStart[2] = cgi.MSG_ReadCoord();
i = cgi.MSG_ReadByte();
if( msgtype == 23 ) {
s = va( "models/fx/crates/debris_%i.tik", i );
} else {
s = va( "models/fx/windows/debris_%i.tik", i );
}
VectorSet( axis[0], 0.f, 0.f, 1.f );
VectorSet( axis[1], 0.f, 1.f, 0.f );
VectorSet( axis[2], 1.f, 0.f, 0.f );
cgi.R_SpawnEffectModel( s, vecStart, axis );
break;
case 25: // Bullet tracer
vecTmp[0] = cgi.MSG_ReadCoord();
vecTmp[1] = cgi.MSG_ReadCoord();
vecTmp[2] = cgi.MSG_ReadCoord();
vecStart[0] = cgi.MSG_ReadCoord();
vecStart[1] = cgi.MSG_ReadCoord();
vecStart[2] = cgi.MSG_ReadCoord();
vecArray[0][0] = cgi.MSG_ReadCoord();
vecArray[0][1] = cgi.MSG_ReadCoord();
vecArray[0][2] = cgi.MSG_ReadCoord();
iLarge = cgi.MSG_ReadBits( 1 );
CG_MakeBulletTracer(vecTmp,vecStart,vecArray,1,iLarge,0,1);
break;
case 26: // Bullet tracer
vecTmp[0] = 0;
vecTmp[1] = 0;
vecTmp[2] = 0;
vecStart[0] = cgi.MSG_ReadCoord();
vecStart[1] = cgi.MSG_ReadCoord();
vecStart[2] = cgi.MSG_ReadCoord();
vecArray[0][0] = cgi.MSG_ReadCoord();
vecArray[0][1] = cgi.MSG_ReadCoord();
vecArray[0][2] = cgi.MSG_ReadCoord();
iLarge = cgi.MSG_ReadBits( 1 );
CG_MakeBulletTracer(vecTmp,vecStart,vecArray,1,iLarge,0,1);
break;
case CGM_HUDDRAW_SHADER:
index = ReadNumber();
name = cgi.MSG_ReadString();
hud = Hud::FindOrCreate( index );
hud->SetShader( name, -1 , -1 );
break;
case CGM_HUDDRAW_ALIGN:
index = ReadNumber();
hud = Hud::FindOrCreate( index );
hud->SetAlignX( ( hudAlign_t )cgi.MSG_ReadBits( 2 ) );
hud->SetAlignY( ( hudAlign_t )cgi.MSG_ReadBits( 2 ) );
break;
case CGM_HUDDRAW_RECT:
index = ReadNumber();
hud = Hud::FindOrCreate( index );
hud->SetRectX( cgi.MSG_ReadShort() );
hud->SetRectY( cgi.MSG_ReadShort() );
hud->SetRectWidth( cgi.MSG_ReadShort() );
hud->SetRectHeight( cgi.MSG_ReadShort() );
break;
case CGM_HUDDRAW_VIRTUALSIZE:
index = ReadNumber();
hud = Hud::FindOrCreate( index );
hud->SetVirtualSize( cgi.MSG_ReadBits( 1 ) );
break;
case CGM_HUDDRAW_COLOR:
index = ReadNumber();
hud = Hud::FindOrCreate( index );
col_x = cgi.MSG_ReadByte() / 255.0f;
col_y = cgi.MSG_ReadByte() / 255.0f;
col_z = cgi.MSG_ReadByte() / 255.0f;
hud->SetColor( Vector( col_x, col_y, col_z ) );
break;
case CGM_HUDDRAW_ALPHA:
index = ReadNumber();
alpha = cgi.MSG_ReadByte() / 255.0f;
hud = Hud::FindOrCreate( index );
hud->SetAlpha( alpha );
break;
case CGM_HUDDRAW_STRING:
index = ReadNumber();
hud = Hud::FindOrCreate( index );
hud->SetText( cgi.MSG_ReadString() );
break;
case CGM_HUDDRAW_FONT:
index = ReadNumber();
hud = Hud::FindOrCreate( index );
hud->SetFont( cgi.MSG_ReadString() );
break;
case 35:
case 36:
*current_entity_number = cg->snap->ps.clientNum;
if( msgtype == 36 )
{
s = "dm_kill_notify";
}
else
{
s = "dm_hit_notify";
}
commandManager->PlaySound( ( const char * )s,
Vector( 0, 0, 0 ),
5,
2.0,
-1.0,
-1.0,
1 );
//CG_PlaySound( s, 0, 5, 2.0, -1.0, vecStart, 1 );
break;
case 37: // voicechat message (squad command, taunt, etc...)
vecStart[0] = cgi.MSG_ReadCoord();
vecStart[1] = cgi.MSG_ReadCoord();
vecStart[2] = cgi.MSG_ReadCoord();
iTemp = cgi.MSG_ReadBits( 1 );
// read client index
i = cgi.MSG_ReadBits( 6 );
// read voicechat sound alias
s = cgi.MSG_ReadString();
if( iTemp ) {
*current_entity_number = i;
}
//CG_Printf("Case 37: iTemp %i, i %i, s %s\n",iTemp,i,s);
// play an aliased sound from uberdialog.scr
// wombat: only if there is a sound to be played
if ( *s ) {
commandManager->PlaySound( s, vecStart, 5, -1.0, -1.0, -1.0, 0 );
}
break;
case CGM_VIEWMODELANIM:
name = cgi.MSG_ReadStringLine();
bFullAnim = cgi.MSG_ReadByte();
CG_ViewModelAnim(( char * )name, bFullAnim );
break;
case CGM_VIEWMODELPREFIX:
weapname = cgi.MSG_ReadStringLine();
prefix = cgi.MSG_ReadString();
VM_AddViewModelPrefix( weapname, prefix );
break;
case CGM_MODHEIGHTFLOAT:
modheightfloat_used = true;
viewHeight = cgi.MSG_ReadLong();
max_z = cgi.MSG_ReadFloat();
break;
case CGM_SETVMASPEED:
name = cgi.MSG_ReadStringLine();
speed = cgi.MSG_ReadFloat();
CG_SetVMASpeed( name, speed );
break;
case CGM_HUDDRAW_TIMER:
index = ReadNumber();
time = cgi.MSG_ReadFloat();
fade_at_time = cgi.MSG_ReadFloat();
time_up = cgi.MSG_ReadBits( 1 );
hud = Hud::FindOrCreate( index );
if( !time_up ) {
hud->SetTimer( time, fade_at_time );
} else {
hud->SetTimerUp( time, fade_at_time );
}
break;
case CGM_HUDDRAW_3D:
index = ReadNumber();
vector_or_offset[ 0 ] = cgi.MSG_ReadCoord();
vector_or_offset[ 1 ] = cgi.MSG_ReadCoord();
vector_or_offset[ 2 ] = cgi.MSG_ReadCoord();
ent_num = cgi.MSG_ReadShort();
always_show = cgi.MSG_ReadBits( 1 );
has_depth = cgi.MSG_ReadBits( 1 );
hud = Hud::FindOrCreate( index );
hud->Set3D( vector_or_offset, always_show, has_depth, ent_num );
break;
case CGM_HUDDRAW_BREAK3D:
index = ReadNumber();
hud = Hud::FindOrCreate( index );
hud->SetNon3D();
break;
case CGM_HUDDRAW_FADE:
index = ReadNumber();
time = cgi.MSG_ReadFloat();
hud = Hud::FindOrCreate( index );
hud->FadeOverTime( time );
break;
case CGM_HUDDRAW_MOVE:
index = ReadNumber();
time = cgi.MSG_ReadFloat();
hud = Hud::FindOrCreate( index );
hud->MoveOverTime( time );
break;
case CGM_HUDDRAW_SCALE:
index = ReadNumber();
time = cgi.MSG_ReadFloat();
width = cgi.MSG_ReadShort();
height = cgi.MSG_ReadShort();
hud = Hud::FindOrCreate( index );
hud->ScaleOverTime( time, width, height );
break;
case CGM_HINTSTRING: // approaching an entity which have an hint string
hint = cgi.MSG_ReadStringLine();
CG_ShowHint( hint );
break;
case CGM_PLAYLOCALSOUND:
s = cgi.MSG_ReadStringLine();
loop = cgi.MSG_ReadBits( 1 );
time = cgi.MSG_ReadFloat();
volume = cgi.MSG_ReadFloat();
commandManager->PlayLocalSound( s, loop, volume, time );
break;
case CGM_STOPLOCALSOUND:
s = cgi.MSG_ReadStringLine();
time = cgi.MSG_ReadFloat();
commandManager->StopLocalSound( s, time );
break;
case CGM_SETLOCALSOUNDRATE:
s = cgi.MSG_ReadStringLine();
rate = cgi.MSG_ReadFloat();
time = cgi.MSG_ReadFloat();
commandManager->SetLocalSoundRate( s, rate, time );
break;
case CGM_HUDDRAW_RECTX:
index = ReadNumber();
hud = Hud::FindOrCreate( index );
hud->SetRectX( cgi.MSG_ReadShort() );
break;
case CGM_HUDDRAW_RECTY:
index = ReadNumber();
hud = Hud::FindOrCreate( index );
hud->SetRectY( cgi.MSG_ReadShort() );
break;
case CGM_HUDDRAW_RECTWH:
index = ReadNumber();
hud = Hud::FindOrCreate( index );
hud->SetRectWidth( cgi.MSG_ReadShort() );
hud->SetRectHeight( cgi.MSG_ReadShort() );
break;
case CGM_REPLICATION:
index = cgi.MSG_ReadBits( 4 );
name = cgi.MSG_ReadString();
{
ScriptVariable var;
var.SetKey( Director.AddString( name ) );
switch( index )
{
case VARIABLE_CHAR:
var.setCharValue( cgi.MSG_ReadChar() );
player.replication.ReplicateVariable( var );
break;
case VARIABLE_CONSTSTRING:
case VARIABLE_STRING:
var.setStringValue( cgi.MSG_ReadString() );
player.replication.ReplicateVariable( var );
break;
case VARIABLE_FLOAT:
var.setFloatValue( cgi.MSG_ReadFloat() );
player.replication.ReplicateVariable( var );
break;
case VARIABLE_INTEGER:
var.setIntValue( cgi.MSG_ReadLong() );
player.replication.ReplicateVariable( var );
break;
case VARIABLE_VECTOR:
vecTmp[ 0 ] = cgi.MSG_ReadCoord();
vecTmp[ 1 ] = cgi.MSG_ReadCoord();
vecTmp[ 2 ] = cgi.MSG_ReadCoord();
var.setVectorValue( ( Vector )vecTmp );
player.replication.ReplicateVariable( var );
break;
}
}
break;
case CGM_HUDDRAW_DELETE:
hud = Hud::Find( cgi.MSG_ReadShort() );
if( hud )
{
delete hud;
}
break;
}
} while( cgi.MSG_ReadBits( 1 ) );
}
/*void __stdcall CG_ParseCGMessage( int msgtype )
{
int index;
float duration, fade_out_time;
hdElement_t *hde;
hdExtend_t *hdex;
const char *weap_name;
const char *prefix;
const char *name;
qboolean bFullAnim;
vec3_t vector;
int ent_num;
qboolean bAlwaysShow, bDepth;
const char * hintstring;
float col_x, col_y, col_z;
Hud *hud;
switch(msgtype)
{
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
case 25:
case 26:
break;
case CGM_HUDDRAW_SHADER:
index = cgi.MSG_ReadByte();
name = cgi.MSG_ReadString();
hud = Hud::FindOrCreate( index );
hud->SetShader( name, -1 , -1 );
break;
case CGM_HUDDRAW_ALIGN:
index = cgi.MSG_ReadByte();
hud = Hud::FindOrCreate( index );
hud->SetAlignX( ( hudAlign_t )cgi.MSG_ReadBits( 2 ) );
hud->SetAlignY( ( hudAlign_t )cgi.MSG_ReadBits( 2 ) );
break;
case CGM_HUDDRAW_RECT:
index = cgi.MSG_ReadByte();
hud = Hud::FindOrCreate( index );
hud->SetRectX( cgi.MSG_ReadShort() );
hud->SetRectY( cgi.MSG_ReadShort() );
hud->SetRectHeight( cgi.MSG_ReadShort() );
hud->SetRectWidth( cgi.MSG_ReadShort() );
break;
case CGM_HUDDRAW_VIRTUALSIZE:
index = cgi.MSG_ReadByte();
hud = Hud::FindOrCreate( index );
hud->SetVirtualSize( cgi.MSG_ReadBits( 1 ) );
break;
case CGM_HUDDRAW_COLOR:
index = cgi.MSG_ReadByte();
hud = Hud::FindOrCreate( index );
col_x = cgi.MSG_ReadByte() / 255.0f;
col_y = cgi.MSG_ReadByte() / 255.0f;
col_z = cgi.MSG_ReadByte() / 255.0f;
hud->SetColor( Vector( col_x, col_y, col_z ) );
break;
case CGM_HUDDRAW_ALPHA:
index = cgi.MSG_ReadByte();
hud = Hud::FindOrCreate( index );
hud->SetAlpha( cgi.MSG_ReadByte() / 255.0f );
break;
case CGM_HUDDRAW_STRING:
index = cgi.MSG_ReadByte();
hud = Hud::FindOrCreate( index );
hud->SetText( cgi.MSG_ReadString() );
break;
case CGM_HUDDRAW_FONT:
index = cgi.MSG_ReadByte();
hud = Hud::FindOrCreate( index );
hud->SetFont( cgi.MSG_ReadString() );
break;
case 35:
case 36:
case 37:
break;
case CGM_HUDDRAW_TIMER: // huddraw_timer
index = cgi.MSG_ReadByte();
duration = cgi.MSG_ReadFloat();
fade_out_time = cgi.MSG_ReadFloat();
hde = cgi.hudDrawElements + index;
hdex = huddrawExtends + index;
hde->shader = 0;
memset(hde->shaderName, 0, sizeof(hde->shaderName));
if(duration <= 0.0f)
memset(&hdex->timer, 0, sizeof(hdTimer_t));
else
{
hdex->timer.bEnabled = true;
hdex->timer.duration = duration;
hdex->timer.current = duration;
hdex->timer.fade_out_time = fade_out_time * 1000.0f;
hdex->timer.alpha = hde->color[3];
strcpy(hde->string, hdex->timer.string);
}
break;
case CGM_VIEWMODELANIM: // viewmodelanim
name = cgi.MSG_ReadStringLine();
bFullAnim = cgi.MSG_ReadByte();
CG_ViewModelAnim((char*)name, bFullAnim);
break;
case CGM_VIEWMODELPREFIX: // viewmodelprefix
weap_name = cgi.MSG_ReadStringLine();
prefix = cgi.MSG_ReadString();
VM_AddViewModelPrefix( weap_name, prefix );
break;
case CGM_MODHEIGHTFLOAT: // modheightfloat
modheightfloat_used = true;
viewHeight = cgi.MSG_ReadLong();
max_z = cgi.MSG_ReadFloat();
break;
case CGM_SETBOBSPEED: // setviewbobspeed
bobMovementMultiplier = cgi.MSG_ReadFloat();
break;
case CGM_HUDDRAW_3D: // huddraw_3d
index = cgi.MSG_ReadByte();
vector[0] = cgi.MSG_ReadCoord();
vector[1] = cgi.MSG_ReadCoord();
vector[2] = cgi.MSG_ReadCoord();
ent_num = cgi.MSG_ReadShort();
bAlwaysShow = cgi.MSG_ReadByte();
bDepth = cgi.MSG_ReadByte();
hde = cgi.hudDrawElements + index;
hdex = huddrawExtends + index;
hdex->h3d.bEnabled = true;
VectorCopy( vector, hdex->h3d.vector );
VectorCopy( vector, hdex->h3d.currentOrg );
hdex->h3d.ent_num = ent_num;
hdex->h3d.bAlwaysShow = bAlwaysShow;
hdex->h3d.bDepth = bDepth;
hde->x = hdex->h3d.x;
hde->y = hdex->h3d.y;
break;
case CGM_HINTSTRING: // approaching an entity which have an hint string
hintstring = cgi.MSG_ReadStringLine();
CG_ShowHint( hintstring );
break;
case CGM_HUDDRAW_FADE:
case CGM_HUDDRAW_MOVE:
case CGM_HUDDRAW_SCALE:
case 48:
case 49:
case 50:
case 51:
case 52:
break;
default:
cgi.Error( ERR_DROP, "CG_ParseCGMessage: Unknown CGM message type" );
}
}*/
-164
View File
@@ -1,164 +0,0 @@
#include "glb_local.h"
#include "cg_viewmodelanim.h"
#include "cl_sound.h"
#include "script/earthquake.h"
#include "script/clientservercommand.h"
void CG_AddViewModelPrefix(const char * weapon_name, const char * prefix);
void CG_ServerCommand()
{
/*const char *command = cgi.Argv( 0 );
char *param1 = cgi.Argv( 1 );
char *param2 = cgi.Argv( 2 );
char *param3 = cgi.Argv( 3 );
char *param4 = cgi.Argv( 4 );
char *param5 = cgi.Argv( 5 );
char *param6 = cgi.Argv( 6 );
char *param7 = cgi.Argv( 7 );
char *param8 = cgi.Argv( 8 );
char *param9 = cgi.Argv( 9 );
char *param10 = cgi.Argv( 10 );*/
char *buffer[ MAX_STRING_CHARS ];
int arguments = cgi.Argc();
for( int i = 0; i < arguments; i++ ) {
buffer[ i ] = cgi.Argv( i );
}
svcommandManager.ExecuteCommand( buffer, arguments );
/*if(strcmp(command, "viewmodelanim") == 0)
{
vm_anim_name = param1;
if(param2)
vm_fullanim = atoi(param2);
else
vm_fullanim = 0;
}
else if(strcmp(command, "viewmodelprefix") == 0)
CG_AddViewModelPrefix(param1, param2);
else if(strcmp(command, "modheightfloat") == 0)
{
__try
{
modheightfloat_used = qtrue;
viewHeight = atoi(param1);
max_z = (float)atof(param2);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
}
else if(strcmp(command, "setviewbobspeed") == 0)
{
__try
{
bobMovementMultiplier = atof(param1);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
}*/
/*if(strcmp(command, "visioneffect") == 0)
{
char * name = param1;
float fadetime, intensity, red, green, blue;
float parameters[2];
vec3_t colors;
qboolean effectAdd;
effectAdd = atoi(param2);
fadetime = (float)atof(param3);
intensity = (float)atof(param4);
red = (float)atof(param5);
green = (float)atof(param6);
blue = (float)atof(param7);
parameters[0] = (float)atof(param8);
parameters[1] = (float)atof(param9);
colors[0] = red;
colors[1] = green;
colors[2] = blue;
R_PostProcessEffect(name, intensity, colors, fadetime, effectAdd, parameters);
}
else if(strcmp(command, "fadesound2") == 0)
{
float time;
float min_vol;
time = (float)atof(param1);
min_vol = (float)atof(param2);
CL_FadeSound2(time, min_vol);
}
else if(strcmp(command, "restoresound") == 0)
{
float time;
float max_vol;
time = (float)atof(param1);
max_vol = (float)atof(param2);
CL_RestoreSound(time, max_vol);
}
else if( strcmp( command, "eq" ) == 0 )
{
float duration;
float magnitude;
qboolean no_rampup;
qboolean no_rampdown;
str location;
float radius;
duration = ( float )atof( param1 );
magnitude = ( float )atof( param2 );
no_rampup = atoi( param3 );
no_rampdown = atoi( param4 );
if( param5 && param6 && param7 )
{
location = param5;
location += str( " " ) + param6;
location += str( " " ) + param7;
radius = ( float )atof( param8 );
}
Earthquake * earthquake = new Earthquake;
earthquake->SetDuration( duration );
earthquake->SetMagnitude( magnitude );
earthquake->SetNoRampup( no_rampup );
earthquake->SetNoRampdown( no_rampdown );
if( location )
{
earthquake->SetLocation( Vector( location.c_str() ) );
earthquake->SetRadius( radius );
}
earthquake->Enable();
} else if ( strcmp( command, "vsn" ) == 0 ) {
R_ProcessVision( param1, atof( param2 ) );
}
else if( strcmp( command, "setshader" ) == 0 )
{
int ent_num = -1;
const char * shadername = NULL;
qboolean fReset = false;
ent_num = atoi( param1 );
shadername = param2;
fReset = atoi( param3 );
R_SetShader( ent_num, shadername, fReset );
} else {
cgi.Printf( "Unknown client game command: %s\n", command );
}*/
}
-7
View File
@@ -1,7 +0,0 @@
#ifndef __SERVERCMDS_H__
#define __SERVERCMDS_H__
void __stdcall CG_ParseCGMessage(int msgtype);
void CG_ServerCommand();
#endif
File diff suppressed because it is too large. Load diff
-55
View File
@@ -1,55 +0,0 @@
#ifndef __VIEWMODELANIM_H__
#define __VIEWMODELANIM_H__
typedef struct vma_s {
str name;
float speed;
} vma_t;
void CG_AddViewModelPrefix( const char * weapon_name, const char * prefix );
void __stdcall CG_CalcViewBob( float value );
void CG_ProcessDeltaAngles( void );
void CG_OffsetFirstPersonView( refEntity_t *model, int a2 );
void CG_OffsetThirdPersonView();
void CG_OffsetThirdPersonViewReal();
void CG_ModelAnim( centity_t *ent, int un1 );
void CG_GetViewModelAnimName( char * Dest, char * Format, char * prefix, char * anim_name );
char * CG_GetViewModelAnimPrefix();
const char *CG_GetCurrentWeaponName( void );
const char *CG_GetCurrentWeaponPrefix( void );
vma_t *CG_GetVMA( const char *name );
//int CG_GetVMAnimPrefixString(char * weapon_name);
void CG_HeightCheck( void );
void CG_MatchEyesBone( refEntity_t * model );
void CG_MoveWeapon( int frametime );
void CG_SetVMASpeed( const char *vma, float speed );
void CG_SetViewHeight( int newHeight );
void CG_ViewInit( void );
void CG_ViewModelAnim( char *name, qboolean bFullAnim );
//char * CG_ViewModelAnimCheck();
void CG_ViewModelAnimCheck( clientAnim_t * anim );
void CG_ViewModelUninitialize( void );
extern uintptr_t CG_OffsetFirstPersonView_f;
extern uintptr_t CG_OffsetThirdPersonView_f;
extern uintptr_t CG_ModelAnim_f;
extern vec3_t currentDeltaVMPosOffset;
extern vec3_t oldAngles;
extern vec3_t deltaAngles;
extern double bobMovementMultiplier;
extern int internal_bobOffset;
extern float max_z;
extern int viewHeight ;
extern qboolean modheightfloat_used ;
extern char vm_anim_name[ MAX_STRING_CHARS ];
extern qboolean vm_fullanim;
extern float vm_time;
#endif
-100
View File
@@ -1,100 +0,0 @@
#include "glb_local.h"
#include "cl_sound.h"
uint8_t *bFadeSoundOrig = ( uint8_t * )0x007F7371;
qboolean *bFadeSoundTrack = ( qboolean * )0x007F7410;
/*DWORD *sound_frame = (DWORD*)0x00FF2A14;
float *fade_soundorig_frame = (float*)0x007F5D68;
float *fade_soundorig_time = (float*)0x007F5D50;*/
qboolean bFadeSound;
float sound_fade_startvol;
float sound_fade_time;
float sound_fade_minvol;
qboolean bRestoreSound;
float sound_restore_startvol;
float sound_restore_time;
float sound_restore_maxvol;
float *sound_global_volume = (float*)0x00551A4C;
void CL_FadeSound2(float time, float min_volume)
{
cgi.Printf("Called FadeSound with: %f %f\n", time, min_volume);
if(bRestoreSound)
bRestoreSound = 0;
if(*sound_global_volume < min_volume)
{
*sound_global_volume = min_volume;
return;
}
bFadeSound = 1;
sound_fade_startvol = *sound_global_volume;
sound_fade_time = time;
sound_fade_minvol = min_volume;
}
void CL_RestoreSound(float time, float max_volume)
{
cgi.Printf("Called RestoreSound with: %f %f\n", time, max_volume);
if(bFadeSound || *bFadeSoundOrig)
{
*bFadeSoundOrig = false;
bFadeSound = 0;
}
if(*sound_global_volume > max_volume)
{
*sound_global_volume = max_volume;
return;
}
bRestoreSound = 1;
sound_restore_startvol = *sound_global_volume;
sound_restore_time = time;
sound_restore_maxvol = max_volume;
}
void CL_SoundProcessing(int frametime)
{
float volume = *sound_global_volume;
if(bFadeSound)
{
volume -= (1.0f-sound_fade_minvol)/sound_fade_time * frametime;
*sound_global_volume = volume;
if(*sound_global_volume < sound_fade_minvol)
{
*sound_global_volume = sound_fade_minvol;
bFadeSound = false;
*bFadeSoundTrack = false;
}
*bFadeSoundTrack = true;
}
if(bRestoreSound)
{
volume += (sound_restore_maxvol)/sound_restore_time * frametime;
*sound_global_volume = volume;
if(*sound_global_volume > sound_restore_maxvol)
{
*sound_global_volume = sound_restore_maxvol;
bRestoreSound = false;
*bFadeSoundTrack = false;
}
*bFadeSoundTrack = true;
}
}
-10
View File
@@ -1,10 +0,0 @@
#ifndef __CL_SOUND_H__
#define __CL_SOUND_H__
extern float *sound_global_volume;
void CL_FadeSound2(float time, float min_volume);
void CL_RestoreSound(float time, float max_volume);
void CL_SoundProcessing(int frametime);
#endif // __CL_SOUND_H__
-592
View File
@@ -1,592 +0,0 @@
#include "glb_local.h"
#include "cgame/cg_hook.h"
#include "cgame/cg_hud.h"
#include "cgame/cg_servercmds.h"
#include "cgame/cg_viewmodelanim.h"
#include "cgame/cl_sound.h"
#include <iostream>
#include <fstream>
#include "archive.h"
#include "script/cplayer.h"
#include "level.h"
#include "script/clientgamecommand.h"
#include "ogl/opengl_api.h"
#include "cgamex86.h"
#include "renderer/qfx_library.h"
#include "renderer/qfx_log.h"
#include "renderer/qfx_settings.h"
#include "renderer/qfx_opengl.h"
#include "renderer/qfx_renderer.h"
#include "renderer/qfx_shader.h"
#include "renderer/qfx_glprogs.h"
#include <world.h>
#include <scriptmaster.h>
HMODULE hmod;
uintptr_t dwCGameBase = 0;
qboolean inited = false;
CG_CONFIGSTRING CG_ConfigString = (CG_CONFIGSTRING)0x30023FA7;
SPRINTF2 sprintf2 = (SPRINTF2)0x3005D214;
Q_STRCMPI Q_strcmpi = (Q_STRCMPI)0x3005DC34;
typedef clientGameExport_t* (*pGetCGameAPI_spec)( void );
pGetCGameAPI_spec pGetCGameAPI;
pfnCG_CastFootShadow CG_CastFootShadow = ( pfnCG_CastFootShadow )0x30029AA4;
CG_PlaySound_f CG_PlaySound = (CG_PlaySound_f)0x30015E0C;
CG_Trace_t CG_Trace = (CG_Trace_t)0x30031BCB;
HINSTANCE hSystem86 = NULL;
typedef void *( *pSystemMalloc_spec )( int size );
extern pSystemMalloc_spec pSystemMalloc;
typedef void( *pSystemFree_spec )( void *ptr );
extern pSystemFree_spec pSystemFree;
pSystemMalloc_spec pSystemMalloc = NULL;
pSystemFree_spec pSystemFree = NULL;
clientGameExport_t cge;
clientGameImport_t cgi;
refImport_t ri;
refExport_t re;
cg_t *cg;
cgs_t *cgs;
centity_t *cg_entities;
centity_t *cent = NULL;
cvar_t *developer;
cvar_t *timescale;
cvar_t *cg_debugview;
cvar_t *cg_hud;
cvar_t *cl_run;
cvar_t *fs_basepath;
cvar_t *r_anaglyph;
cvar_t *ui_hud;
cvar_t *vm_offset_air_up;
cvar_t *vm_offset_air_side;
cvar_t *vm_offset_air_front;
cvar_t *vm_offset_crouch_side;
cvar_t *vm_offset_vel_up;
cvar_t *vm_offset_vel_side;
cvar_t *vm_offset_vel_front;
cvar_t *archive_save;
cvar_t *s_volume;
cvar_t *cg_showopcodes;
cvar_t *cg_scriptcheck;
cvar_t *cl_scriptfiles;
qboolean reborn;
float *viewAngles = (float*)0x01100B14;
int RenderedScene[5];
int cg_frametime;
qboolean fUnloading = false;
extern qboolean render_inited;
extern void R_Init();
regCvar_t cvars[] = {
{ &developer, "developer", "0", CVAR_ARCHIVE },
{ &cg_debugview, "cg_debugview", "0", CVAR_ARCHIVE },
{ &cg_hud, "cg_hud", "1", 0 },
{ &cl_run, "cl_run", "1", CVAR_ARCHIVE },
{ &fs_basepath, "fs_basepath", "", CVAR_ARCHIVE },
{ &r_anaglyph, "r_anaglyph", "0", CVAR_ARCHIVE },
{ &ui_hud, "ui_hud", "1", 0 },
{ &vm_offset_air_up, "vm_offset_air_up", "-2.0", CVAR_ARCHIVE },
{ &vm_offset_air_side, "vm_offset_air_side", "0", CVAR_ARCHIVE },
{ &vm_offset_air_front, "vm_offset_air_front", "0", CVAR_ARCHIVE },
{ &vm_offset_crouch_side, "vm_offset_crouch_side", "1.5", CVAR_ARCHIVE },
{ &vm_offset_vel_up, "vm_offset_vel_up", "0", CVAR_ARCHIVE },
{ &vm_offset_vel_side, "vm_offset_vel_side", "0", CVAR_ARCHIVE },
{ &vm_offset_vel_front, "vm_offset_vel_front", "0", CVAR_ARCHIVE },
{ &archive_save, "archive_save", "0", CVAR_ARCHIVE },
{ &s_volume, "s_volume", "0.9", CVAR_ARCHIVE },
{ &cg_showopcodes, "cg_showopcodes", "0", CVAR_ARCHIVE },
{ &cg_scriptcheck, "cg_scriptcheck", "0", CVAR_ARCHIVE },
{ &cl_scriptfiles, "cl_scriptfiles", "0", CVAR_ARCHIVE },
{ NULL, NULL, NULL, NULL },
};
//===================================================================
void QDECL Com_Error( int level, const char *error, ... ) {
va_list argptr;
char text[ 1024 ];
va_start( argptr, error );
vsprintf( text, error, argptr );
va_end( argptr );
cgi.Error( ( errorParm_t )level, "%s", text );
}
void QDECL Com_Printf( const char *msg, ... ) {
va_list argptr;
char text[ 1024 ];
va_start( argptr, msg );
vsprintf( text, msg, argptr );
va_end( argptr );
cgi.Printf( "%s", text );
}
void *( *CL_Malloc )( int size );
void ( *CL_Free )( void *ptr );
void* CG_Malloc( int size )
{
return CL_Malloc( size );
}
void CG_Free( void *ptr )
{
int zoneId = *( int * )( ( unsigned char * )ptr - 4 );
int size = ( int )( ( unsigned char * )ptr - 16 );
assert( ptr );
if( zoneId == 0xC057 )
return;
assert( zoneId == 0x2015 );
if( zoneId != 0x2015 )
return;
assert( *( unsigned int * )( *( unsigned int * )size + size - 4 ) == 0x2015 );
if( *( unsigned int * )( *( unsigned int * )size + size - 4 ) != 0x2015 )
return;
CL_Free( ptr );
}
void dummy_Printf( char * format, ... )
{
}
centity_t * CG_GetEntity( int ent_num )
{
entityState_t * ce = NULL;
int i;
for( i = 0; i < cg->activeSnapshots[ 0 ].numEntities; i++ )
{
if( cg->activeSnapshots[ 0 ].entities[ i ].number == ent_num ) {
ce = &cg->activeSnapshots[ 0 ].entities[ i ];
}
}
return ( centity_t * )ce;
}
void debug_save()
{
Archiver arc;
if( !arc.Create( "test.reborn" ) ) {
cgi.Printf( "error saving to file\n" );
return;
}
//Class::PrepareArchive( arc );
arc.Close();
cgi.Printf( "successfully saved\n" );
}
void debug_restore()
{
Archiver arc;
if( !arc.Read( "test.reborn" ) )
{
cgi.Printf( "error restoring from file\n" );
return;
}
//Class::PrepareArchive( arc );
arc.Close();
cgi.Printf( "successfully restored\n" );
}
const char *CG_GetServerInfo()
{
return cgs->gameState.stringData
+ cgs->gameState.stringOffsets[ CS_SERVERINFO ];
}
const char *CG_GetServerVariable( const char *variable )
{
return Info_ValueForKey( CG_GetServerInfo(), variable );
}
qboolean script_loaded = false;
void CG_DrawActiveFrame( int serverTime, int frametime, stereoFrame_t stereoView, qboolean demoPlayback )
{
if( !render_inited ) {
R_Init();
}
if( frametime < 1 )
{
frametime = 1;
}
level.setFrametime( frametime );
level.setTime( serverTime );
//ScriptTimer::HandleTimer( ( float )frametime );
L_ProcessPendingEvents();
if( !script_loaded )
{
script_loaded = true;
ClientGameCommandManager::Initialize();
//ClientScript::AutoLoadScripts();
}
if( archive_save->integer == 1 )
{
cgi.Cvar_Set( "archive_save", "0" );
debug_save();
}
else if( archive_save->integer == 2 )
{
cgi.Cvar_Set( "archive_save", "0" );
debug_restore();
}
cg_frametime = frametime;
R_ProcessEffectsFade( frametime );
CL_SoundProcessing( frametime );
CL_ProcessCEntities();
if( cg_debugview->integer )
{
if( cg->snap != NULL ) {
cg->snap->ps.pm_flags = 0;
}
if( cg->nextSnap != NULL ) {
cg->nextSnap->ps.pm_flags = 0;
}
cg->activeSnapshots[0].ps.pm_flags = 0;
cg->activeSnapshots[1].ps.pm_flags = 0;
cg->predictedPlayerState.pm_flags = 0;
}
cge.CG_DrawActiveFrame( serverTime, frametime, stereoView, demoPlayback );
}
void CG_Shutdown(void)
{
//CG_ViewModelUninitialize();
ClientGameCommandManager::CleanUp();
cge.CG_Shutdown();
/* Unload the original cgamex86mohaa to prevent crashes because of the
* replaced instructions
*/
//FreeLibrary( hmod );
}
void R_RenderScene( refDef_t *fd );
int R_CvarSize( void );
void CG_InitCvars( void )
{
int i;
for ( i = 0 ; i < sizeof( cvars ) / sizeof( cvars[0] ) ; i++ )
{
if( cvars[i].cvar == NULL ) {
continue;
}
*cvars[i].cvar = cgi.Cvar_Get( cvars[i].name, cvars[i].value, cvars[i].flags );
}
for ( i = 0 ; i < R_CvarSize() ; i++ )
{
if( r_cvars[i].cvar == NULL ) {
continue;
}
*r_cvars[i].cvar = cgi.Cvar_Get( r_cvars[i].name, r_cvars[i].value, r_cvars[i].flags );
}
}
float Anim_FrameTime( dtiki_t *tiki, int animNum )
{
float time = cgi.Anim_Frametime( tiki, animNum );
time /= 2.f;
return time;
}
int GetSnapshot( int snapshotNumber, snapshot_t *snapshot )
{
int result = cgi.GetSnapshot( snapshotNumber, snapshot );
return result;
}
void CG_Init( clientGameImport_t *imported, int serverMessageNum, int serverCommandSequence, int clientNum )
{
CL_Malloc = imported->Malloc;
imported->Malloc = CG_Malloc;
CL_Free = imported->Free;
imported->Free = CG_Free;
memcpy( &cgi, imported, sizeof( cgi ) );
imported->R_RenderScene = R_RenderScene;
imported->R_AddRefEntityToScene = R_AddRefEntityToScene;
imported->R_AddRefSpriteToScene = R_AddRefSpriteToScene;
imported->GetSnapshot = GetSnapshot;
//cvars
menu = cgi.Cvar_Get( "menu", "0", CVAR_ARCHIVE );
stats = cgi.Cvar_Get( "stats", "0", CVAR_ARCHIVE );
timescale = cgi.Cvar_Get( "timescale", "1.0", CVAR_CHEAT );
CG_ViewInit();
huddrawExtends = (hdExtend_t*)malloc(sizeof(hdExtend_t) * 256);
memset(huddrawExtends, 0, sizeof(huddrawExtends) * 256);
CG_InitCvars();
Director.Reset();
L_InitEvents();
world = new World;
player.SetTargetName( "player" );
cge.CG_Init( imported, serverMessageNum, serverCommandSequence, clientNum );
char buffer[ MAX_QPATH ];
strcpy( buffer, cgs->mapName + 5 );
COM_StripExtension( buffer, buffer, sizeof( buffer ) );
try
{
Director.ExecuteThread( "clientscripts/maps/" + str( buffer ) + ".ccr", "" );
}
catch( ScriptException& exc )
{
glbs.Printf( "%s\n", exc.string.c_str() );
}
level.AddWaitTill( "prespawn" );
level.Unregister( "prespawn" );
//level.prespawned = true;
const char *value = CG_GetServerVariable( "sv_reborn" );
if( value != NULL && isdigit( *value ) ) {
reborn = !!atoi( value );
} else {
reborn = false;
}
R_ProcessVision( buffer, 0.f );
level.AddWaitTill( "spawn" );
level.Unregister( "spawn" );
Director.Reset( false );
//level.spawned = true;
/* char tmp[ MAX_STRINGCHARS ];
int intValue;
Archiver arc;
if( !arc.FileExists( "main/test.reborn" ) )
{
arc.Save( "main/test.reborn" );
} else {
arc.Load( "main/test.reborn" );
}
if( arc.Loading() ) {
arc.RemoveSave();
}
ClientObject::PrepareArchive( arc );
arc.Dump();
arc.Close();*/
}
qboolean CG_ConsoleCommand( void )
{
char *cmd = cgi.Argv( 0 );
ScriptThreadLabel *label = m_scriptCmds.findKeyValue( cmd );
if( label != NULL )
{
Event event;
for( int i = 1; i < cgi.Argc(); i++ )
{
event.AddString( cgi.Argv( i ) );
}
label->Execute( NULL, event );
}
return cge.CG_ConsoleCommand();
}
/*
================
GetCGameAPI
The only exported function from this module
================
*/
clientGameExport_t* GetCGameAPI( void )
{
clientGameExport_t *exp = pGetCGameAPI();
memcpy( &cge, exp, sizeof(cge) );
exp->CG_Init = CG_Init;
//exp->CG_ParseCGMessage = CG_ParseCGMessage;
exp->CG_Draw2D = CG_Draw2D;
exp->CG_DrawActiveFrame = CG_DrawActiveFrame;
exp->CG_Shutdown = CG_Shutdown;
exp->CG_ParseCGMessage = CG_ParseCGMessage2;
exp->CG_ConsoleCommand = CG_ConsoleCommand;
//exp->CG_Command_ProcessFile = CG_Command_ProcessFile;
return exp;
}
void fuck_cgi_printf_crash_noob_shit( const char *fmt, ... )
{
}
BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
char path[MAX_PATH];
int i;
switch ( ul_reason_for_call )
{
case DLL_PROCESS_ATTACH:
if( inited ) {
return TRUE;
}
inited = true;
/*GetModuleFileName( NULL, path, sizeof(path) );
for ( i=strlen(path); i>0; i-- )
{
if (path[i] == '\\')
{
path[i+1] = 0;
break;
}
}*/
hmod = LoadLibrary( "main\\cgamex86mohaa.dll" );
if ( !hmod )
{
printf( "LoadLibrary failed: \"0x%lX\"\n", GetLastError() );
exit( GetLastError() );
}
pGetCGameAPI = (pGetCGameAPI_spec)GetProcAddress( hmod, "GetCGameAPI" );
dwCGameBase = PtrToUlong( hmod );
uid = ( uidef_t * )0xBF3B78;
keys = ( qkey_t * )0x12F4B20;
cg = ( cg_t * )( dwCGameBase + 0x2B7DC0 );
cgs = ( cgs_t * )( dwCGameBase + 0x2A5460 );
cg_entities = ( centity_t * )( dwCGameBase + 0x3FDA00 );
/*RenderedScene[0] = (int *)0x01313938;
RenderedScene[1] = (int *)0x01313940;
RenderedScene[2] = (int *)0x01313934;
RenderedScene[3] = (int *)0x01313950;
RenderedScene[4] = (int *)0x0131394C;*/
hSystem86 = LoadLibraryA( "system86.dll" );
pSystemMalloc = (pSystemMalloc_spec)GetProcAddress( hSystem86, "MemoryMalloc" );
pSystemFree = ( pSystemFree_spec )GetProcAddress( hSystem86, "MemoryFree" );
CG_HookClientGame();
break;
case DLL_PROCESS_DETACH:
fUnloading = true;
// Remove the OpenGL hooks when disconnecting/changing maps
R_Shutdown();
FreeLibrary( hmod );
break;
}
return TRUE;
}
void loadDll()
{
if ( !inited ) {
DllMain( GetModuleHandle( 0 ), DLL_PROCESS_ATTACH, NULL );
}
}
-788
View File
@@ -1,788 +0,0 @@
#ifndef __CGAMEX86_H__
#define __CGAMEX86_H__
#include "hook.h"
#include "renderer_api.h"
#include "../game/bg_public.h"
#define MAX_CVARS 255;
typedef struct {
cvar_t **cvar;
const char *name;
const char *value;
int flags;
} regCvar_t;
typedef struct centity_s
{
entityState_t currentState;
entityState_t nextState;
int teleported;
int interpolate;
int currentValid;
int miscTime;
int snapShotTime;
int errorTime;
vec3_t errorOrigin;
vec3_t errorAngles;
int extrapolated;
vec3_t rawOrigin;
vec3_t rawAngles;
vec3_t beamEnd;
vec3_t lerpOrigin;
vec3_t lerpAngles;
int tikiLoopSound;
float tikiLoopSoundVolume;
float tikiLoopSoundMinDist;
float tikiLoopSoundMaxDist;
float tikiLoopSoundPitch;
int tikiLoopSoundFlags;
vec4_t color;
vec4_t clientColor;
int clientFlags;
int splashLastSpawnTime;
int splashStillCount;
vec4_t boneQuat[ 5 ];
float animLastTimes[ MAX_FRAMEINFOS ];
int animLast[ MAX_FRAMEINFOS ];
int animLastWeight;
int usageIndexLast;
int footOnGround_Right;
int footOnGround_Left;
int nextLandTime;
} centity_t;
typedef void ( __stdcall *CG_PlaySound_f )( char *sound_name, float *origin, int channel,
float volume, float min_distance, float pitch, int argstype );
extern CG_PlaySound_f CG_PlaySound;
typedef void ( *CG_Trace_t )(trace_t *results, const vec3_t start, const vec3_t mins ,
const vec3_t maxs, const vec3_t end, int headnode, int brushmask, int cylinder,
qboolean bClipEntities, char *description);
extern CG_Trace_t CG_Trace;
void CG_ParseCGMessage2( void );
class CPlayer;
extern uintptr_t dwCGameBase;
extern pmove_t * pm;
extern cvar_t *developer;
extern cvar_t *timescale;
extern cvar_t *cg_debugview;
extern cvar_t *cg_hud;
extern cvar_t *cl_run;
extern cvar_t *fs_basepath;
extern cvar_t *r_anaglyph;
extern cvar_t *ui_hud;
extern cvar_t *vm_offset_air_up;
extern cvar_t *vm_offset_air_side;
extern cvar_t *vm_offset_air_front;
extern cvar_t *vm_offset_crouch_side;
extern cvar_t *vm_offset_vel_up;
extern cvar_t *vm_offset_vel_side;
extern cvar_t *vm_offset_vel_front;
extern cvar_t *s_volume;
extern cvar_t *cg_showopcodes;
extern cvar_t *cg_scriptcheck;
extern cvar_t *cl_scriptfiles;
extern regCvar_t r_cvars[];
class Entity;
extern qboolean reborn;
centity_t * CG_GetEntity(int ent_num);
Entity *R_SpawnModel( const char *model, vec3_t origin, vec3_t angles );
const char *CG_GetServerInfo();
const char *CG_GetServerVariable( const char *variable );
#define ITEM_MAX_NAME 255
#define ITEM_MAX_PREFIX 255 // 255 is enough for a list of new items
typedef struct serverSound_s
{
vec3_t origin;
int entityNumber;
int channel;
short int soundIndex;
float volume;
float minDist;
float maxDist;
float pitch;
qboolean stopFlag;
qboolean streamed;
} serverSound_t;
typedef struct snapshot_s
{
int snapFlags;
int ping;
int serverTime;
unsigned char areaMask[ 32 ];
playerState_t ps;
int numEntities;
entityState_t entities[ 1024 ];
int numServerCommands;
int serverCommandSequence;
int numberOfSounds;
serverSound_t sounds[ 64 ];
} snapshot_t;
typedef struct baseShader_s
{
char shader[ MAX_QPATH ];
int surfaceFlags;
int contentFlags;
} baseShader_t;
typedef struct clientInfo_s
{
int team;
} clientInfo_t;
typedef struct objective_s
{
char text[ MAX_STRING_CHARS ];
int flags;
} objective_t;
typedef struct rain_s
{
float density;
float speed;
int speedVary;
int slant;
float length;
float minDist;
float width;
char shader[ 16 ][ MAX_STRING_CHARS ];
int numShaders;
} rain_t;
typedef struct cgs_s
{
gameState_t gameState;
glconfig_t glConfig;
float screenXScale;
float screenYScale;
float screenXBias;
int serverCommandSequence;
int processedSnapshotNum;
qboolean localServer;
int levelStartTime;
int matchEndTime;
int serverLagTime;
int gameType;
int dmFlags;
int teamFlags;
int fragLimit;
int timeLimit;
int maxClients;
int cinematic;
char mapName[MAX_QPATH];
int modelDraw[MAX_MODELS];
int soundPrecache[MAX_SOUNDS];
int numInlineModels;
int inlineDrawModel[MAX_MODELS];
vec3_t inlineModelMidpoints[MAX_MODELS];
media_t media;
} cgs_t;
typedef struct cg_s
{
int clientFrame;
int clientNum;
int demoPlayback;
int levelShot;
int latestSnapshotNum;
int latestSnapshotTime;
snapshot_t *snap;
snapshot_t *nextSnap;
snapshot_t activeSnapshots[ 2 ];
float frameInterpolation;
int thisFrameTeleport;
int nextFrameTeleport;
int nextFrameCameraCut;
int frametime;
int time;
int physicsTime;
int renderingThirdPerson;
int hyperSpace;
playerState_t predictedPlayerState;
int validPPS;
int predictedErrorTime;
vec3_t predictedError;
int weaponCommand;
int weaponCommandSend;
vec3_t autoAngles;
vec3_t autoAxis[3];
vec3_t autoAnglesSlow;
vec3_t autoAxisSlow[3];
vec3_t autoAnglesFast;
vec3_t autoAxisFast[3];
refDef_t refdef;
vec3_t playerHeadPos;
vec3_t refdefViewAngles;
vec3_t currentViewPos;
vec3_t currentViewAngles;
float currentViewHeight;
float currentViewBobPhase;
float currentViewBobAmp;
dtiki_t *lastPlayerWorldModel;
dtiki_t *playerFPSModel;
int playerFPSModelHandle;
int fpsModelLastFrame;
int fpsOnGround;
dtiki_t *alliedPlayerModel;
int alliedPlayerModelHandle;
dtiki_t *axisPlayerModel;
int axisPlayerModelHandle;
vec3_t offsetViewAngles;
vec3_t lastHeadAngles;
vec3_t lastViewAngles;
vec3_t eyeOffsetMax;
float eyeOffsetFrac;
vec3_t soundOrg;
vec3_t soundAxis[3];
vec3_t cameraOrigin;
vec3_t cameraAngles;
float cameraFov;
float zoomSensitivity;
int intermissionDisplay;
int scoresRequestTime;
int showScores;
char scoresMenuName[256];
int instaMessageMenu;
int centerPrintTime;
int centerPrintCharWidth;
int centerPrintY;
char centerPrint[1024];
int centerPrintLines;
int matchStartTime;
refEntity_t testModelEntity;
char testModelName[MAX_QPATH];
int testGun;
float farplaneDistance;
float farplaneColor[3];
int farplaneCull;
int skyPortal;
float skyAlpha;
vec3_t skyOrigin;
vec3_t skyAxis[3];
vec2_t viewKick;
float viewKickRecenter;
float viewKickMinDecay;
float viewKickMaxDecay;
objective_t objectives[ MAX_OBJECTIVES ];
float objectivesAlphaTime;
float objectivesBaseAlpha;
float objectivesDesiredAlpha;
float objectivesCurrentAlpha;
rain_t rain;
clientInfo_t clientinfo[MAX_CLIENTS];
} cg_t;
typedef struct uidef_s
{
int time;
int vidWidth;
int vidHeight;
int mouseX;
int mouseY;
unsigned int mouseFlags;
qboolean uiHasMouse;
} uidef_t;
//
// cl_input
//
typedef struct {
int down[2]; // key nums holding it down
unsigned downtime; // msec timestamp
unsigned msec; // msec down this frame if both a down and up happened
qboolean active; // current state
qboolean wasPressed; // set when down, not cleared when up
} kbutton_t;
typedef struct qkey_s
{
qboolean down;
int repeats;
char *binding;
} qkey_t;
typedef struct fontHandle_s
{
int bla;
} fontHandle_t;
typedef struct clientAnim_s
{
frameInfo_t vmFrameInfo[MAX_FRAMEINFOS];
int lastVMAnim;
int lastVMAnimChanged;
int currentVMAnimSlot;
int currentVMDuration;
qboolean crossBlending;
int lastEquippedWeaponStat;
char lastActiveItem[80];
int lastAnimPrefixIndex;
vec3_t currentVMPosOffset;
unsigned char un1[72];
dtiki_t * tiki;
} clientAnim_t;
typedef struct hdElement_s
{
qhandle_t shader;
char shaderName[MAX_QPATH];
int x;
int y;
int width;
int height;
vec4_t color;
int horizontalAlign;
int verticalAlign;
qboolean virtualScreen;
char string[MAX_STRING_CHARS];
char fontName[MAX_QPATH];
fontHeader_t *font;
} hdElement_t;
typedef struct stopWatch_s
{
int startTime;
int endTime;
} stopWatch_t;
typedef enum keyNum_e
{
K_TAB = 9,
K_ENTER = 13,
K_ESCAPE = 27,
K_SPACE = 32,
K_BACKSPACE = 127,
K_COMMAND,
K_CAPSLOCK,
K_POWER,
K_PAUSE,
K_UPARROW,
K_DOWNARROW,
K_LEFTARROW,
K_RIGHTARROW,
K_LALT,
K_LCTRL,
K_LSHIFT,
K_RALT,
K_RCTRL,
K_RSHIFT,
K_INS,
K_DEL,
K_PGDN,
K_PGUP,
K_HOME,
K_END,
K_F1,
K_F2,
K_F3,
K_F4,
K_F5,
K_F6,
K_F7,
K_F8,
K_F9,
K_F10,
K_F11,
K_F12,
K_F13,
K_F14,
K_F15,
K_KPHOME,
K_KPUPARROW,
K_KPPGUP,
K_KPLEFTARROW,
K_KP5,
K_KPRIGHTARROW,
K_KPEND,
K_KPDOWNARROW,
K_KPPGDN,
K_KPENTER,
K_KPINS,
K_KPDEL,
K_KPSLASH,
K_KPMINUS,
K_KPPLUS,
K_KPNUMLOCK,
K_KPSTAR,
K_KPEQUALS,
K_MOUSE1,
K_MOUSE2,
K_MOUSE3,
K_MOUSE4,
K_MOUSE5,
K_MWHEELDOWN,
K_MWHEELUP,
K_JOY1,
K_JOY2,
K_JOY3,
K_JOY4,
K_JOY5,
K_JOY6,
K_JOY7,
K_JOY8,
K_JOY9,
K_JOY10,
K_JOY11,
K_JOY12,
K_JOY13,
K_JOY14,
K_JOY15,
K_JOY16,
K_JOY17,
K_JOY18,
K_JOY19,
K_JOY20,
K_JOY21,
K_JOY22,
K_JOY23,
K_JOY24,
K_JOY25,
K_JOY26,
K_JOY27,
K_JOY28,
K_JOY29,
K_JOY30,
K_JOY31,
K_JOY32,
K_AUX1,
K_AUX2,
K_AUX3,
K_AUX4,
K_AUX5,
K_AUX6,
K_AUX7,
K_AUX8,
K_AUX9,
K_AUX10,
K_AUX11,
K_AUX12,
K_AUX13,
K_AUX14,
K_AUX15,
K_AUX16,
K_LWINKEY,
K_RWINKEY,
K_MENUKEY,
K_LASTKEY
} keyNum_t;
// Dump memory to a file then read it
typedef struct tmpArchive
{
} tmpArchive;
typedef struct profVar_s
{
int start;
int clockCycles;
int calls;
float time;
float totTime;
float avgTime;
float low;
float high;
} profVar_t;
typedef struct profCGame_s
{
profVar_t CG_AddCEntity;
profVar_t CG_DrawActiveFrame;
profVar_t CG_AddPacketEntities;
profVar_t CG_DrawActive;
profVar_t CG_EntityShadow;
profVar_t CG_Rain;
profVar_t CG_AddBeams;
profVar_t CG_ModelAnim;
profVar_t CG_ProcessSnapshots;
profVar_t CProbe1;
profVar_t CProbe2;
profVar_t CProbe3;
} profCGame_t;
typedef struct clientGameImport_s
{
int apiVersion;
void ( *Printf )( const char *fmt, ... );
void ( *DPrintf )( const char *fmt, ... );
void ( *DebugPrintf )( const char *fmt, ... );
void * ( *Malloc )( size_t size );
void ( *Free )( void *ptr );
void ( *Error )( errorParm_t code, const char *fmt, ... );
int ( *Milliseconds )( );
char * ( *LV_ConvertString )( const char *string );
cvar_t * ( *Cvar_Get )( const char *varName, const char *varValue, int varFlags );
void ( *Cvar_Set )( const char *varName, const char *varValue );
int ( *Argc )( );
char * ( *Argv )( int arg );
char * ( *Args )( );
void ( *AddCommand )( char *cmdName, xcommand_t cmdFunction );
void ( *Cmd_Stuff )( const char *text );
void ( *Cmd_Execute )( cbufExec_t execWhen, char *text );
void ( *Cmd_TokenizeString )( char *textIn );
int ( *FS_ReadFile )( const char *qpath, void **buffer, qboolean bSilent );
void ( *FS_FreeFile )( void *buffer );
int ( *FS_WriteFile )( const char *qpath, void *buffer, int size );
void ( *FS_WriteTextFile )( const char *qpath, void *buffer, int size );
void ( *SendConsoleCommand )( const char *text );
int ( *MSG_ReadBits )( int bits );
int ( *MSG_ReadChar )( );
int ( *MSG_ReadByte )( );
int ( *MSG_ReadSVC )( );
int ( *MSG_ReadShort )( );
int ( *MSG_ReadLong )( );
float ( *MSG_ReadFloat )( );
char * ( *MSG_ReadString )( );
char * ( *MSG_ReadStringLine )( );
float ( *MSG_ReadAngle8 )( );
float ( *MSG_ReadAngle16 )( );
void ( *MSG_ReadData )( void *data, int len );
float ( *MSG_ReadCoord )( );
void ( *MSG_ReadDir )( vec3_t dir );
void ( *SendClientCommand )( const char *text );
void ( *CM_LoadMap )( char *name );
clipHandle_t ( *CM_InlineModel )( int index );
int ( *CM_NumInlineModels )( );
int ( *CM_PointContents )( vec3_t point, clipHandle_t model );
int ( *CM_TransformedPointContents )( vec3_t point, clipHandle_t model, vec3_t origin, vec3_t angles );
void ( *CM_BoxTrace )( trace_t *results, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, int model, int brushMask, int cylinder );
void ( *CM_TransformedBoxTrace )( trace_t *results, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, int model, int brushMask, vec3_t origin, vec3_t angles, int cylinder );
clipHandle_t ( *CM_TempBoxModel )( vec3_t mins, vec3_t maxs, int contents );
void ( *CM_PrintBSPFileSizes )( );
qboolean ( *CM_LeafInPVS )( int leaf1, int leaf2 );
int ( *CM_PointLeafnum )( vec3_t p );
int ( *R_MarkFragments )( int numPoints, vec3_t *points, vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer, float fRadiusSquared );
int ( *R_MarkFragmentsForInlineModel )( clipHandle_t bmodel, vec3_t vAngles, vec3_t vOrigin, int numPoints, vec3_t *points, vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer, float fRadiusSquared );
void ( *R_GetInlineModelBounds )( int index, vec3_t mins, vec3_t maxs );
void ( *R_GetLightingForDecal )( vec3_t light, vec3_t facing, vec3_t origin );
void ( *R_GetLightingForSmoke )( vec3_t light, vec3_t origin );
int ( *R_GatherLightSources )( vec3_t pos, vec3_t *lightPos, vec3_t *lightIntensity, int maxLights );
void ( *S_StartSound )( vec3_t origin, int entNum, int entChannel, sfxHandle_t sfxHandle, float volume, float minDist, float pitch, float maxDist, int streamed );
void ( *S_StartLocalSound )( char *soundName, int channel );
void ( *S_StopSound )( int entNum, int channel );
void ( *S_ClearLoopingSounds )( );
void ( *S_AddLoopingSound )( vec3_t origin, vec3_t velocity, sfxHandle_t sfxHandle, float volume, float minDist, float maxDist, float pitch, int flags );
void ( *S_Respatialize )( int entityNum, vec3_t head, vec3_t axis[3] );
void ( *S_BeginRegistration )( );
sfxHandle_t ( *S_RegisterSound )( char *name, int streamed, qboolean forceLoad );
void ( *S_EndRegistration )( );
void ( *S_UpdateEntity )( int entityNum, vec3_t origin, vec3_t velocity, qboolean useListener );
void ( *S_SetReverb )( int reverbType, float reverbLevel );
void ( *S_SetGlobalAmbientVolumeLevel )( float volume );
float ( *S_GetSoundTime )( sfxHandle_t handle );
int ( *S_ChannelNameToNum )( char *name );
char * ( *S_ChannelNumToName )( int channel );
int ( *S_IsSoundPlaying )( int channelNumber, char *name );
void ( *MUSIC_NewSoundtrack )( char *name );
void( *MUSIC_UpdateMood )( music_mood_t current, music_mood_t fallback );
void ( *MUSIC_UpdateVolume )( float volume, float fadeTime );
float * ( *get_camera_offset )( qboolean *lookActive, qboolean *resetView );
void ( *R_ClearScene )( );
void ( *R_RenderScene )( refDef_t *fd );
void ( *R_LoadWorldMap )( char *name );
void ( *R_PrintBSPFileSizes )( );
int ( *MapVersion )( );
int ( *R_MapVersion )( );
qhandle_t ( *R_RegisterModel )( const char *name );
qhandle_t ( *R_SpawnEffectModel )( const char *name, vec3_t pos, vec3_t axis[3] );
qhandle_t ( *R_RegisterServerModel )( const char *name );
void ( *R_UnregisterServerModel )( qhandle_t hModel );
qhandle_t ( *R_RegisterSkin )( const char *name );
qhandle_t ( *R_RegisterShader )( const char *name );
qhandle_t ( *R_RegisterShaderNoMip )( const char *name );
void ( *R_AddRefEntityToScene )( refEntity_t *ent, int parentEntityNumber );
void ( *R_AddRefSpriteToScene )( refEntity_t *ent );
void ( *R_AddLightToScene )( vec3_t org, float intensity, float r, float g, float b, dlightType_t type );
qboolean ( *R_AddPolyToScene )( qhandle_t hShader, int numVerts, polyVert_t *verts, int renderFx );
void ( *R_AddTerrainMarkToScene )( int terrainIndex, qhandle_t hShader, int numVerts, polyVert_t *verts, int renderFx );
void ( *R_SetColor )( vec4_t rgba );
void ( *R_DrawStretchPic )( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );
fontHeader_t * ( *R_LoadFont )( const char *name );
void ( *R_DrawString )( fontHeader_t *font, const char *text, float x, float y, int maxLen, qboolean virtualScreen );
refEntity_t * ( *R_GetRenderEntity )( int entityNumber );
void ( *R_ModelBounds )( clipHandle_t model, vec3_t mins, vec3_t maxs );
float ( *R_ModelRadius )( qhandle_t handle );
float ( *R_Noise )( float x, float y, float z, float t );
void ( *R_DebugLine )( vec3_t start, vec3_t end, float r, float g, float b, float alpha );
baseShader_t * ( *GetShader )( int shaderNum );
void ( *R_SwipeBegin )( float thistime, float life, qhandle_t shader );
void ( *R_SwipePoint )( vec3_t point1, vec3_t point2, float time );
void ( *R_SwipeEnd )( );
int ( *R_GetShaderWidth )( qhandle_t hShader );
int ( *R_GetShaderHeight )( qhandle_t hShader );
void ( *R_DrawBox )( float x, float y, float w, float h );
void ( *GetGameState )( gameState_t *gameState );
int ( *GetSnapshot )( int snapshotNumber, snapshot_t *snapshot );
int ( *GetServerStartTime )( );
void ( *SetTime )( float time );
void ( *GetCurrentSnapshotNumber )( int *snapshotNumber, int *serverTime );
void ( *GetGlconfig )( glconfig_t *glConfig );
qboolean ( *GetParseEntityState )( int parseEntityNumber, entityState_t *state );
int ( *GetCurrentCmdNumber )( );
qboolean ( *GetUserCmd )( int cmdNumber, usercmd_t *userCmd );
qboolean ( *GetServerCommand )( int serverCommandNumber, qboolean differentServer );
qboolean ( *Alias_Add )( char *alias, char *name, char *parameters );
qboolean ( *Alias_ListAdd )( AliasList_t *list, const char *alias, const char *name, const char *parameters );
char * ( *Alias_FindRandom )( const char *alias, AliasListNode_t **ret );
char * ( *Alias_ListFindRandom )( AliasList_t *list, const char *alias, AliasListNode_t **ret );
void ( *Alias_Dump )( );
void ( *Alias_Clear )( );
AliasList_t * ( *AliasList_New )( char *name );
void ( *Alias_ListFindRandomRange )( AliasList_t *list, char *alias, int *minIndex, int *maxIndex, float *totalWeight );
AliasList_t * ( *Alias_GetGlobalList )( );
void ( *UI_ShowMenu )( char *name, qboolean bForce );
void ( *UI_HideMenu )( char *name, qboolean bForce );
int ( *UI_FontStringWidth )( fontHeader_t *font, char *string, int maxLen );
int ( *Key_StringToKeynum )( char *str );
char * ( *Key_KeynumToBindString )( int keyNum );
void ( *Key_GetKeysForCommand )( const char *command, int *key1, int *key2 );
dtiki_t * ( *R_Model_GetHandle )( qhandle_t handle );
int ( *TIKI_NumAnims )( dtiki_t *pmdl );
void ( *TIKI_CalculateBounds )( dtiki_t *pmdl, float scale, vec3_t mins, vec3_t maxs );
char * ( *TIKI_Name )( dtiki_t *tiki, int entNum );
void * ( *TIKI_GetSkeletor )( dtiki_t *tiki, int entNum );
void ( *TIKI_SetEyeTargetPos )( dtiki_t *tiki, int entNum, vec3_t pos );
char * ( *Anim_NameForNum )( dtiki_t *tiki, int animNum );
int ( *Anim_NumForName )( dtiki_t *tiki, const char *name );
int ( *Anim_Random )( dtiki_t *tiki, const char *name );
int ( *Anim_NumFrames )( dtiki_t *tiki, int animNum );
float ( *Anim_Time )( dtiki_t *tiki, int animNum );
float ( *Anim_Frametime )( dtiki_t *tiki, int animNum );
void ( *Anim_Delta )( dtiki_t *tiki, int animNum, vec3_t delta );
int ( *Anim_Flags )( dtiki_t *tiki, int animNum );
int ( *Anim_FlagsSkel )( dtiki_t *tiki, int animNum );
float ( *Anim_CrossblendTime )( dtiki_t *tiki, int animNum );
qboolean ( *Anim_HasCommands )( dtiki_t *tiki, int animNum );
qboolean ( *Frame_Commands )( dtiki_t *tiki, int animNum, int frameNum, tiki_cmd_t *tikiCmds );
qboolean ( *Frame_CommandsTime )( dtiki_t *pmdl, int animNum, float start, float end, tiki_cmd_t *tikiCmd );
int ( *Surface_NameToNum )( dtiki_t *pmdl, const char *name );
int ( *Tag_NumForName )( dtiki_t *pmdl, const char *name );
char * ( *Tag_NameForNum )( dtiki_t *pmdl, int animNum );
void ( *ForceUpdatePose )( refEntity_t *model );
orientation_t ( *TIKI_Orientation )( orientation_t *orientation, refEntity_t *model, int tagNum );
qboolean ( *TIKI_IsOnGround )( refEntity_t *model, int tagNum, float threshold );
void ( *UI_ShowScoreBoard )( const char *menuName );
void ( *UI_HideScoreBoard )( );
void ( *UI_SetScoreBoardItem )( int itemNumber, char *data1, char *data2, char *data3, char *data4, char *data5, char *data6, char *data7, char *data8, float *textColor, float *backColor, qboolean isHeader );
void ( *UI_DeleteScoreBoardItems )( int maxIndex );
void ( *UI_ToggleDMMessageConsole )( int consoleMode );
dtiki_t * ( *TIKI_FindTiki )( char *path );
void ( *LoadResource )( char *name );
void ( *FS_CanonicalFilename )( char *name );
cvar_t *fsDebug;
hdElement_t *hudDrawElements;
clientAnim_t *anim;
stopWatch_t *stopWatch;
int( *FS_Read )( void *buffer, int len, fileHandle_t fileHandle );
void( *FS_FCloseFile )( fileHandle_t fileHandle );
int( *FS_Tell )( fileHandle_t fileHandle );
int( *FS_Seek )( fileHandle_t fileHandle, long int offset, fsOrigin_t origin );
fileHandle_t( *FS_FOpenFileWrite )( const char *fileName );
int( *FS_Write )( void *buffer, int size, fileHandle_t fileHandle );
char **( *FS_ListFiles )( const char *qpath, const char *extension, qboolean wantSubs, int *numFiles );
void( *FS_FreeFileList )( char **list );
} clientGameImport_t;
typedef struct clientGameExport_s
{
void ( *CG_Init )( clientGameImport_t *imported, int serverMessageNum, int serverCommandSequence, int clientNum );
void ( *CG_Shutdown )( );
void ( *CG_DrawActiveFrame )( int serverTime, int frameTime, stereoFrame_t stereoView, qboolean demoPlayback );
qboolean ( *CG_ConsoleCommand )( );
void ( *CG_GetRendererConfig )( );
void ( *CG_Draw2D )( );
void ( *CG_EyePosition )( vec3_t *eyePos );
void ( *CG_EyeOffset )( vec3_t *eyeOffset );
void ( *CG_EyeAngles )( vec3_t *eyeAngles );
float ( *CG_SensitivityScale )( );
void ( *CG_ParseCGMessage )( );
void ( *CG_RefreshHudDrawElements )( );
void ( *CG_HudDrawShader )( int info );
void ( *CG_HudDrawFont )( int info );
int ( *CG_GetParent )( int entNum );
float ( *CG_GetObjectiveAlpha )( );
int ( *CG_PermanentMark )( vec3_t origin, vec3_t dir, float orientation, float sScale, float tScale, float red, float green, float blue, float alpha, qboolean doLighting, float sCenter, float tCenter, markFragment_t *markFragments, void *polyVerts );
int ( *CG_PermanentTreadMarkDecal )( treadMark_t *treadMark, qboolean startSegment, qboolean doLighting, markFragment_t *markFragments, void *polyVerts );
int ( *CG_PermanentUpdateTreadMark )( treadMark_t *treadMark, float alpha, float minSegment, float maxSegment, float maxOffset, float texScale );
void ( *CG_ProcessInitCommands )( dtiki_t *tiki, refEntity_t *ent );
void ( *CG_EndTiki )( dtiki_t *tiki );
char * ( *CG_GetColumnName )( int columnNum, int *columnWidth );
void ( *CG_GetScoreBoardColor )( float *red, float *green, float *blue, float *alpha );
void ( *CG_GetScoreBoardFontColor )( float *red, float *green, float *blue, float *alpha );
int ( *CG_GetScoreBoardDrawHeader )( );
void ( *CG_GetScoreBoardPosition )( float *x, float *y, float *width, float *height );
int ( *CG_WeaponCommandButtonBits )( );
int ( *CG_CheckCaptureKey )( keyNum_t key, qboolean down, unsigned int time );
profCGame_t *profStruct;
qboolean ( *CG_Command_ProcessFile )( char *name, qboolean quiet, dtiki_t *curTiki );
} clientGameExport_t;
clientGameExport_t * GetCGameAPI( );
extern cg_t *cg;
extern cgs_t *cgs;
extern centity_t *cg_entities;
extern centity_t *cent;
extern float *viewAngles;
extern int cg_frametime;
extern clientGameExport_t cge;
extern clientGameImport_t cgi;
typedef char* (__cdecl * CG_CONFIGSTRING)(int ID);
extern CG_CONFIGSTRING CG_ConfigString;
typedef char* (__cdecl *SPRINTF2)(char * Format, ...);
extern SPRINTF2 sprintf2;
typedef int (__cdecl *Q_STRCMPI)(char * Str1, char * Str2);
extern Q_STRCMPI Q_strcmpi;
typedef void ( __cdecl *pfnCG_CastFootShadow )( vec3_t lightPos, vec3_t lightIntensity, int tagNum, refEntity_t *ref );
extern pfnCG_CastFootShadow CG_CastFootShadow;
#endif /* __CGAMEX86_H */
-62
View File
@@ -1,62 +0,0 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code 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.
OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// game.cpp : TU Game.
#include "game.h"
Game game;
void CacheResource( const char *name )
{
}
SimpleEntity *G_FindTarget( SimpleEntity *next, const char *classname )
{
return NULL;
}
Vector G_GetMovedir( float angle )
{
if( angle == -1.0f )
{
return Vector( 0.0f, 0.0f, 1.0f );
}
else if( angle == -2.0f )
{
return Vector( 0.0f, 0.0f, -1.0f );
}
angle *= ( M_PI * 2.0f / 360.0f );
return Vector( cos( angle ), sin( angle ), 0.0f );
}
float G_Random( float value )
{
return fmod( rand(), value );
}
CLASS_DECLARATION( Listener, Game, NULL )
{
{ NULL, NULL }
};
-40
View File
@@ -1,40 +0,0 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code 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.
OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// game.h : TU Game.
#ifndef __GAME_H__
#define __GAME_H__
#include <listener.h>
class Game : public Listener {
CLASS_PROTOTYPE( Game );
};
extern Game game;
SimpleEntity *G_FindTarget( SimpleEntity *next, const char *classname );
Vector G_GetMovedir( float angle );
float G_Random( float value );
#endif /* __GAME_H__*/
-414
View File
@@ -1,414 +0,0 @@
/*
===========================================================================
Copyright (C) 2008 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code 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.
OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// hook.cpp : Hooks & Detours
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#define _WINSOCKAPI_
#include "windows.h"
#else
#include <sys/mman.h>
#endif
#include "glb_local.h"
#include <float.h>
#include "hook.h"
#include "md5.h"
//#pragma warning(disable : 4172)
#pragma warning(disable : 4005 4083 4244 4047 4018 4700)
int bDataCompare( const uint8_t* pData, const uint8_t* bMask, const char* szMask )
{
for(;*szMask;++szMask,++pData,++bMask)
if(*szMask=='x' && *pData!=*bMask )
return 0;
return (*szMask) == 0;
}
uintptr_t dwFindPattern( uintptr_t dwAddress, uintptr_t dwLen, uint8_t *bMask, const char * szMask )
{
DWORD i;
for( i=0; i < dwLen; i++)
if( bDataCompare( (BYTE*)( dwAddress+i ),bMask,szMask) )
return (DWORD)(dwAddress+i);
return 0;
}
void ReadMemory( uintptr_t dwBaseAddress, uint8_t buffer[], uintptr_t dwLen )
{
#ifndef WIN32
int ret = unprotect( GET_PAGE( (void *)dwBaseAddress ), 4096 );
if ( ret == -1 ) {
handle_error( "Read memory error #1" );
}
if ( ( ( (uint)dwBaseAddress ) & 0xfff ) > 0xff9 )
ret = unprotect( GET_PAGE( (void *)dwBaseAddress + 4096 ), 4096 );
if ( ret == -1 ) {
handle_error( "Read memory error #2" );
}
#endif
memcpy( ( void* )buffer, ( void* )dwBaseAddress, dwLen );
}
void WriteMemory( uintptr_t dwBaseAddress, uint8_t buffer[], uintptr_t dwLen )
{
#ifdef WIN32
DWORD old_protection;
DWORD old_protectionRevert;
VirtualProtect( (LPVOID)dwBaseAddress, dwLen+5, PAGE_EXECUTE_READWRITE, &old_protection);
#else
int ret = 0;
ret = unprotect( GET_PAGE( (void *)dwBaseAddress ), 4096 );
if ( ret == -1 ) {
Com_Printf( "dwBaseAddress = %p\n", dwBaseAddress );
handle_error( "Write memory error #1" );
}
if ( ( ( (uint)dwBaseAddress ) & 0xfff ) > 0xff9 )
ret = unprotect( GET_PAGE( (void *)dwBaseAddress + 4096 ), 4096 );
if ( ret == -1 ) {
Com_Printf( "dwBaseAddress = %p\n", dwBaseAddress );
handle_error( "Write memory error #2" );
}
#endif
memcpy( (void*)dwBaseAddress, (void*)buffer, dwLen );
#ifdef WIN32
VirtualProtect( (LPVOID)dwBaseAddress, dwLen+5, old_protection, &old_protectionRevert);
#endif
}
BYTE *detour_function( void *orig, void *detour, int len )
{
if ( orig == NULL || detour == NULL ) {
return NULL;
}
unsigned char *tramp;
unsigned char *tmp;
#ifdef WIN32
DWORD old_protection;
DWORD old_protectionRevert;
#endif
if ( len<5 )
{
Com_Printf( "detour_function : length must be 5 or above (len=%d)! (orig=0x%p|detour=0x%p)\n", len, orig, detour );
cgi.Error( ERR_FATAL, "Wrong length\n" );
return NULL;
}
tramp = (unsigned char *)malloc( len + 5 + ( 2 * sizeof(DWORD) ) );
*( DWORD * )tramp = (DWORD)orig; // store the original function address in the trampoline
*( DWORD * )( tramp + 4 ) = len; // store the length in the trampoline
tramp += 8;
memset( tramp, 0x90, len+5 );
memcpy( tramp, orig, len );
tramp[len] = 0xE9;
*( (void **)( tramp + len + 1 ) ) = (void *)( ( ( (unsigned int)orig ) + len ) - (unsigned int)( tramp + len + 5 ) );
#ifdef WIN32
VirtualProtect( (LPVOID)orig, len+10, PAGE_EXECUTE_READWRITE, &old_protection);
#else
unprotect( GET_PAGE( orig ), 4096 );
if ( ( ( (uint)orig ) & 0xfff ) > 0xff9 )
unprotect( GET_PAGE( orig + 4096 ), 4096 );
#endif
*( (unsigned char *)orig ) = 0xE9;
*( (void **)( (unsigned int)orig + 1 ) ) = (void*)( ( (unsigned int)detour ) - ( ( (unsigned int)orig ) + 5 ) );
tmp = (unsigned char*)( ( (unsigned int)orig ) + 5 );
for ( ; len>5; len--, tmp++ )
*tmp = 0xCC;
#ifdef WIN32
VirtualProtect( (LPVOID)orig, len+10, old_protection, &old_protectionRevert);
#endif
return tramp;
}
void detour_remove( void * orig, void * detour )
{
if ( orig == NULL || detour == NULL ) {
return;
}
#ifdef WIN32
DWORD old_protection;
DWORD old_protectionRevert;
#endif
DWORD dwOld;
int len;
dwOld = *( DWORD * )( ( DWORD )detour - 8 ); // retrieve the original function address from the detour
len = *( DWORD * ) ( ( DWORD )detour - 4 ); // retrieve the length from the detour
#ifdef WIN32
VirtualProtect( (LPVOID)dwOld, len+10, PAGE_EXECUTE_READWRITE, &old_protection);
#else
unprotect( GET_PAGE( dwOld ), 4096 );
if ( ( ( (uint)dwOld ) & 0xfff ) > 0xff9 )
unprotect( GET_PAGE( dwOld + 4096 ), 4096 );
#endif
memcpy( (void*)dwOld, detour, len );
free( ( void* )( ( DWORD )detour - 8 ) );
#ifdef WIN32
VirtualProtect( (LPVOID)orig, len+10, old_protection, &old_protectionRevert);
#endif
}
DWORD DetourPatchcall( PBYTE pSrc, PBYTE pDst, BOOL bForce )
{
DWORD dwOrgCallDest = 0;
DWORD dwOldProtection = 0;
DWORD dwRel = 0;
if(!pSrc || !pDst) return (0);
//type call <rel const>
if( *pSrc == 0xE8 || bForce )
{
if( *pSrc == 0xE8 ){
dwRel = *(DWORD*)( pSrc + 1 );
dwOrgCallDest = ( (DWORD)pSrc + dwRel + 0x5 );
} else {
dwOrgCallDest = 1; // return 1 means no original call at pSrc
}
#ifdef WIN32
if( !VirtualProtect( (PVOID)pSrc, 0x1000, PAGE_EXECUTE_READWRITE, &dwOldProtection ) )
return (0);
#else
unprotect( GET_PAGE( pSrc ), 4096 );
if ( ( ( (unsigned long)pSrc ) & 0xfff ) > 0xff9 )
unprotect( GET_PAGE( pSrc + 4096 ), 4096 );
#endif
*pSrc = 0xE8;
*( DWORD* )( pSrc + 1 ) = (DWORD)( pDst - pSrc - 5 );
#ifdef WIN32
VirtualProtect( (PVOID)pSrc, 0x1000, dwOldProtection, &dwOldProtection );
#endif
return dwOrgCallDest;
}
return (0);
}
char *replace( char *string, const char *search, const char *replace )
{
static char strings[ 2 ][ MAX_STRING_TOKENS ];
static int index = 0;
char *buffer;
buffer = strings[ index & 1 ];
index++;
char *p;
if( !( p = strstr( string, search ) ) ) {
return string;
}
strncpy( buffer, string, p - string ); // Copy characters from 'str' start to 'orig' st$
buffer[ p - string ] = '\0';
sprintf( buffer + ( p - string ), "%s%s", replace, p + strlen( search ) );
return buffer;
}
void replace2( char *s, const char *s1, const char *s2 )
{
char *p, *sp, *dp;
int len, cnt;
for( ;; )
{
if( ( p = strstr( s, s1 ) ) == NULL ) return;
len = strlen( s2 ) - strlen( s1 );
if( len )
{
// Locate the string and replace string length, requiring shift action
sp = p + strlen( s1 ); // From the SP referring location
dp = sp + len; // Move to the location referred to dp
cnt = strlen( sp ) + 1; // The length
memmove( p + strlen( s1 ) + len, p + strlen( s1 ), cnt );
}
memcpy( p, s2, strlen( s2 ) );
}
}
const char *itemName[255] =
{
"",
"Papers",
"Colt 45",
"Walther P38",
"Hi-Standard Silenced",
"M1 Garand",
"Mauser KAR 98K",
"KAR98 - Sniper",
"Springfield '03 Sniper",
"Thompson",
"MP40",
"BAR",
"StG 44",
"Frag Grenade",
"Stielhandgranate",
"Bazooka",
"Panzerschreck",
"Shotgun",
"unarmed",
NULL
};
const char *itemPrefix[255] =
{
"",
"papers",
"colt45",
"p38",
"histandard",
"garand",
"kar98",
"kar98sniper",
"springfield",
"thompson",
"mp40",
"bar",
"mp44",
"fraggrenade",
"stielhandgranate",
"bazooka",
"panzerschreck",
"shotgun",
"unarmed",
NULL
};
void VM_AddViewModelPrefix( const char * weapon_name, const char * prefix )
{
int i;
char *weapon_name_allocated;
char *weapon_prefix_allocated;
for( i = 1; i < 255; i++ )
{
/* Don't add this more than once... */
if( itemPrefix[i] != NULL && _stricmp( itemPrefix[i], prefix ) == 0 && _stricmp( itemName[i], weapon_name ) == 0 ) {
return;
}
}
/* Allocate the name so that it will be always present in the database */
weapon_name_allocated = ( char * )malloc( strnlen( weapon_name, 255 ) );
weapon_prefix_allocated = ( char * )malloc( strnlen( prefix, 255 ) );
strcpy( weapon_name_allocated, weapon_name );
strcpy( weapon_prefix_allocated, prefix );
for( i = 1; i < 255; i++ )
{
if( itemName[i] == NULL || itemPrefix[i] == NULL )
{
itemName[i] = ( char * )weapon_name_allocated;
itemPrefix[i] = ( char * )weapon_prefix_allocated;
break;
}
}
}
int VM_GetVMAnimPrefixString( char * weapon_name )
{
int i;
if( weapon_name == NULL ) {
return 18; // unarmed
}
for( i = 1; i < 255; i++ )
{
if( itemName[i] == NULL ) {
continue;
}
if( _stricmp( itemName[i], weapon_name ) == 0 ) {
return i;
}
}
return 18;
}
void VM_VMInit( void )
{
int i;
for( i = 1; i < 255; i++ )
{
if( itemName[i] == NULL || itemPrefix[i] == NULL ) {
break;
}
}
for( ; i < 255; i ++ )
{
itemName[i] = NULL;
itemPrefix[i] = NULL;
}
}
-129
View File
@@ -1,129 +0,0 @@
/*
===========================================================================
Copyright (C) 2008 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code 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.
OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// hook.h : Hooks & Detours
#if defined ( CGAME_DLL )
#include "cgamex86.h"
#else
#include "ubersdk.h"
#endif
#include "asm.h"
#include "vector.h"
#if defined ( CGAME_DLL )
#define glbs cgi
#else
#define glbs ugi
#endif
//====================
// CGM Messages
//====================
#define CGM_HUDDRAW_SHADER 27
#define CGM_HUDDRAW_ALIGN 28
#define CGM_HUDDRAW_RECT 29
#define CGM_HUDDRAW_VIRTUALSIZE 30
#define CGM_HUDDRAW_COLOR 31
#define CGM_HUDDRAW_ALPHA 32
#define CGM_HUDDRAW_STRING 33
#define CGM_HUDDRAW_FONT 34
#define CGM_HUDDRAW_TIMER 38
#define CGM_HUDDRAW_3D 39
#define CGM_HUDDRAW_BREAK3D 40
#define CGM_HUDDRAW_FADE 41
#define CGM_HUDDRAW_MOVE 42
#define CGM_HUDDRAW_SCALE 43
#define CGM_VIEWMODELANIM 44
#define CGM_VIEWMODELPREFIX 45
#define CGM_MODHEIGHTFLOAT 46
#define CGM_SETVMASPEED 47
#define CGM_HINTSTRING 48
#define CGM_PLAYLOCALSOUND 49
#define CGM_SETLOCALSOUNDRATE 50
#define CGM_STOPLOCALSOUND 51
#define CGM_HUDDRAW_RECTX 52
#define CGM_HUDDRAW_RECTY 53
#define CGM_HUDDRAW_RECTWH 54
#define CGM_REPLICATION 55
#define CGM_HUDDRAW_DELETE 56
//====================
// Hooks & Detours
//====================
#define unprotect(addr,len) (mprotect(addr,len,PROT_READ|PROT_WRITE|PROT_EXEC))
#define GET_PAGE(a) ((void*)(((unsigned long)a)&0xfffff000))
#define handle_error(msg) \
do { perror( msg ); exit( EXIT_FAILURE ); } while ( 0 )
//====================
// Misc Functions
//====================
extern int bDataCompare( const uint8_t* pData, const uint8_t* bMask, const char* szMask );
extern uintptr_t dwFindPattern( uintptr_t dwAddress, uintptr_t dwLen, uint8_t *bMask, const char * szMask );
extern void ReadMemory( uintptr_t dwBaseAddress, uint8_t buffer[], uintptr_t dwLen );
extern void WriteMemory( uintptr_t dwBaseAddress, uint8_t buffer[], uintptr_t dwLen );
uint8_t *detour_function( void * orig, void * detour, int len );
void detour_remove( void * orig, void * detour );
extern uintptr_t DetourPatchcall( uintptr_t pSrc, uintptr_t pDst, uintptr_t bForce );
#define _wpm(a,b,s) WriteProcessMemory(GetCurrentProcess(), (PVOID)(a), (PBYTE)(b), (s), NULL )
char *replace( char *string, const char *search, const char *replace );
void replace2( char *s, const char *s1, const char *s2 );
//====================
// Misc Functions
//====================
extern const char *itemName[];
extern const char *itemPrefix[];
void VM_AddViewModelPrefix( const char * weapon_name, const char * prefix );
int VM_GetVMAnimPrefixString( char * weapon_name );
void VM_VMInit( void );
//++++++++END+++++++++
#ifndef WIN32
void initsighandlers(void);
void resetsighandlers(void);
void sighandler(int sig, siginfo_t *info, void *secret);
#else
void initExceptions( void );
#endif
#ifndef __FUNCTION__
#define __FUNCTION__ const char * function
#endif
-88
View File
@@ -1,88 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////////
// IMAGE.h
// Image class declaration
// Downloaded from: www.paulsprojects.net
// Created: 20th July 2002
// Modified: 9th November 2002 - Corrected stride for TGA textures
// - Split up .cpp files
// - Added support for paletted textures
//
// Copyright (c) 2006, Paul Baker
// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
// http://www.paulsprojects.net/NewBSDLicense.txt)
//////////////////////////////////////////////////////////////////////////////////////////
#ifndef IMAGE_H
#define IMAGE_H
class IMAGE
{
public:
IMAGE() : data(NULL), bpp(0), width(0), height(0), stride(0),
paletted(false), paletteBpp(0), palette(NULL)
{}
~IMAGE()
{
if(data)
delete [] data;
data=NULL;
if(palette)
delete [] palette;
palette=NULL;
}
//Load image
bool Load(char * filename);
//Use the color indices from a paletted image as the alpha channel for this image
bool LoadAlpha(const IMAGE & alphaImage);
protected:
//Load BMPs
bool LoadBMP(char * filename);
bool Load8BitBMP(char * filename);
bool Load24BitBMP(char * filename);
//Load TGAs
bool LoadTGA(char * filename);
bool LoadUncompressed8BitTGA(char * filename);
bool LoadUncompressedTrueColorTGA(char * filename);
bool LoadCompressedTrueColorTGA(char * filename);
//Calculate the number of bytes in a row, including padding bytes
unsigned int CalculateStride(unsigned int testBpp=-1, unsigned int testWidth=-1);
//Do not pass values to use class members
public:
//Alter the image
void FlipVertically(void);
void MirrorHorizontally(void);
void ExpandPalette(void); //convert a paletted image into a non-paletted one
unsigned int bpp; //bits per pixel
unsigned int width, height; //size
unsigned int stride; //bytes per row, including padding bytes
GLuint format; //format (eg GL_RGBA)
//Data
GLubyte * data;
//palette data (256 entries)
bool paletted;
unsigned int paletteBpp;
GLuint paletteFormat;
GLubyte * palette;
};
//Bitmap ID
const DWORD bitmapID=0x4D42;
#endif //IMAGE_H
@@ -1,38 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////////
// IMAGE_CalculateStride.cpp
// Calculate the number of bytes in an image row, including padding bytes
// Downloaded from: www.paulsprojects.net
// Created: 9th November 2002
//
// Copyright (c) 2006, Paul Baker
// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
// http://www.paulsprojects.net/NewBSDLicense.txt)
//////////////////////////////////////////////////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <GL/gl.h>
#include "IMAGE.h"
//Calculate the number of bytes in an image row, including padding bytes
//default parameters (-1, -1). If a parameter is -1, use class varibles
unsigned int IMAGE::CalculateStride(unsigned int testBpp, unsigned int testWidth)
{
//See if we should use the class' own variables
if(testWidth==-1)
testWidth=width;
if(testBpp==-1)
testBpp=bpp;
//Calculate the number of bits per line
unsigned int bitsPerLine=testWidth*testBpp;
//Find how many to add on to make 32-bit aligned
unsigned int bitsToAdd=0;
if((bitsPerLine%32)!=0)
bitsToAdd=32-(bitsPerLine%32);
//return stride
return (bitsPerLine+bitsToAdd)/8;
}
@@ -1,62 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////////
// IMAGE_CalculateStride.cpp
// Convert a paletted image into a non-paletted one
// Downloaded from: www.paulsprojects.net
// Created: 9th November 2002
//
// Copyright (c) 2006, Paul Baker
// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
// http://www.paulsprojects.net/NewBSDLicense.txt)
//////////////////////////////////////////////////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <GL/gl.h>
#include "IMAGE.h"
//Convert a paletted image into a non-paletted one
void IMAGE::ExpandPalette(void)
{
//Do not expand non-paletted images, or those with no data
if(!paletted || !data)
return;
//Calculate the stride of the expanded image
unsigned int newStride=CalculateStride(paletteBpp);
//Create space for the expanded image data
GLubyte * newData=new GLubyte[newStride*height];
if(!newData)
{
printf("Unable to create memory for expanded data\n");
return;
}
//Loop through and fill in the unpaletted data
for(unsigned int row=0; row<height; ++row)
{
for(unsigned int i=0; i<width; ++i)
{
unsigned int currentOldPixel=(row*stride)+i;
unsigned int currentNewPixel=(row*newStride)+i*(paletteBpp/8);
GLubyte currentPaletteEntry=data[((row*stride)+i)];
for(unsigned int j=0; j<paletteBpp/8; ++j)
{
newData[currentNewPixel+j]=
palette[currentPaletteEntry*(paletteBpp/8)+j];
}
}
}
//Update class member variables
paletted=false;
bpp=paletteBpp;
format=paletteFormat;
stride=newStride;
if(data)
delete [] data;
data=newData;
}
-53
View File
@@ -1,53 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////////
// IMAGE_Load.cpp
// Main Image loading function
// Downloaded from: www.paulsprojects.net
// Created: 20th July 2002
// Modified: 9th November 2002 - Corrected stride for TGA textures
// - Split up .cpp files
// - Added support for paletted textures
//
// Copyright (c) 2006, Paul Baker
// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
// http://www.paulsprojects.net/NewBSDLicense.txt)
//////////////////////////////////////////////////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <GL/gl.h>
#include "IMAGE.h"
//Load an image from a file
bool IMAGE::Load(char * filename)
{
//Clear the member variables if already used
bpp=0;
width=height=0;
stride=0;
format=0;
if(data)
delete [] data;
data=NULL;
paletted=false;
paletteBpp=0;
paletteFormat=0;
if(palette)
delete [] palette;
palette=NULL;
//Call the correct loading function based on the filename
int filenameLength=strlen(filename);
if( strncmp(filename+filenameLength-3, "BMP", 3)==0 ||
strncmp(filename+filenameLength-3, "bmp", 3)==0)
return LoadBMP(filename);
if( strncmp(filename+filenameLength-3, "TGA", 3)==0 ||
strncmp(filename+filenameLength-3, "tga", 3)==0)
return LoadTGA(filename);
printf("%s does not end with \"bmp\" or \"tga\"\n", filename);
return false;
}
@@ -1,96 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////////
// IMAGE_Load24BitBMP.cpp
// Load a 24 bit .bmp file
// Downloaded from: www.paulsprojects.net
// Created: 9th November 2002
//
// Copyright (c) 2006, Paul Baker
// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
// http://www.paulsprojects.net/NewBSDLicense.txt)
//////////////////////////////////////////////////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <GL/gl.h>
#include "IMAGE.h"
//Load a 24 bit .bmp file
bool IMAGE::Load24BitBMP(char * filename)
{
printf("Loading %s in Load24BitBMP()\n", filename);
FILE * file;
BITMAPFILEHEADER fileHeader;
BITMAPINFOHEADER infoHeader;
//Open file for reading
file=fopen(filename, "rb");
if(!file)
{
printf("Unable to open %s\n", filename);
return false;
}
//read the file header
fread(&fileHeader, sizeof(BITMAPFILEHEADER), 1, file);
//Check this is a bitmap
if(fileHeader.bfType != bitmapID)
{
fclose(file);
printf("%s is not a legal .bmp\n", filename);
return false;
}
//Read in the information header
fread(&infoHeader, sizeof(BITMAPINFOHEADER), 1, file);
if(infoHeader.biBitCount!=24)
{
fclose(file);
printf("%s is not a 24 bit .bmp\n", filename);
return false;
}
//Set class variables
bpp=24;
format=GL_RGB;
width=infoHeader.biWidth;
height=infoHeader.biHeight;
//Calculate the stride in bytes for each row (allow for 4-byte padding)
stride=CalculateStride();
//Point "file" to the beginning of the data
fseek(file, fileHeader.bfOffBits, SEEK_SET);
//Allocate space for the image data
data=new GLubyte[stride*height];
if(!data)
{
fclose(file);
printf( "Unable to allocate data for %s of size %d x %d\n", filename,
stride, height);
return false;
}
//read in the data
fread(data, 1, stride*height, file);
fclose(file);
//Data is in BGR format
//swap b and r
for(unsigned int row=0; row<height; ++row)
{
for(unsigned int i=0; i<width; ++i)
{
//Repeated XOR to swap bytes 0 and 2
data[(row*stride)+i*3] ^= data[(row*stride)+i*3+2] ^=
data[(row*stride)+i*3] ^= data[(row*stride)+i*3+2];
}
}
printf("Loaded %s Correctly!\n", filename);
return true;
}
-123
View File
@@ -1,123 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////////
// IMAGE_Load8BitBMP.cpp
// Load an 8 bit paletted .bmp file
// Downloaded from: www.paulsprojects.net
// Created: 9th November 2002
//
// Copyright (c) 2006, Paul Baker
// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
// http://www.paulsprojects.net/NewBSDLicense.txt)
//////////////////////////////////////////////////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <GL/gl.h>
#include "IMAGE.h"
//Load an 8 bit .bmp file
bool IMAGE::Load8BitBMP(char * filename)
{
printf("Loading %s in Load8BitBMP()\n", filename);
FILE * file;
BITMAPFILEHEADER fileHeader;
BITMAPINFOHEADER infoHeader;
//Open file for reading
file=fopen(filename, "rb");
if(!file)
{
printf("Unable to open %s\n", filename);
return false;
}
//read the file header
fread(&fileHeader, sizeof(BITMAPFILEHEADER), 1, file);
//Check this is a bitmap
if(fileHeader.bfType != bitmapID)
{
fclose(file);
printf("%s is not a legal .bmp\n", filename);
return false;
}
//Read in the information header
fread(&infoHeader, sizeof(BITMAPINFOHEADER), 1, file);
if(infoHeader.biBitCount!=8)
{
fclose(file);
printf("%s is not an 8 bit .bmp\n", filename);
return false;
}
//Set class variables
bpp=8;
format=GL_COLOR_INDEX;
width=infoHeader.biWidth;
height=infoHeader.biHeight;
paletted=true;
paletteBpp=24;
paletteFormat=GL_RGB;
//Calculate the stride in bytes for each row (allow for 4-byte padding)
stride=CalculateStride();
//Create space for a temporary palette
GLubyte * tempPalette=new GLubyte[256*4];
if(!tempPalette)
{
fclose(file);
printf("Unable to allocate space for palette\n");
return false;
}
//Load the palette
fread(tempPalette, 256*4, 1, file);
//Create space for palette (disregard needless 4th entry)
palette=new GLubyte[256*3];
if(!palette)
{
fclose(file);
printf("Unable to allocate space for palette\n");
return false;
}
//Copy the palette entries from tempPalette to palette
//swap bytes 0 and 2 to go from BGR to RGB
for(int i=0; i<256; ++i)
{
palette[i*3+0]=tempPalette[i*4+2];
palette[i*3+1]=tempPalette[i*4+1];
palette[i*3+2]=tempPalette[i*4+0];
}
//Clear "tempPalette" data
if(tempPalette)
delete [] tempPalette;
tempPalette=NULL;
//Point "file" to the beginning of the data
fseek(file, fileHeader.bfOffBits, SEEK_SET);
//Allocate space for the image data
data=new GLubyte[stride*height];
if(!data)
{
fclose(file);
printf( "Unable to allocate data for %s of size %d x %d\n", filename,
stride, height);
return false;
}
//read in the data
fread(data, 1, stride*height, file);
fclose(file);
printf("Loaded %s Correctly!\n", filename);
return true;
}
-74
View File
@@ -1,74 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////////
// IMAGE_LoadAlpha.cpp
// Use the color indices from a paletted image as the alpha channel for this image
// Downloaded from: www.paulsprojects.net
// Created: 17th November 2002
//
// Copyright (c) 2006, Paul Baker
// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
// http://www.paulsprojects.net/NewBSDLicense.txt)
//////////////////////////////////////////////////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <GL/gl.h>
#include "IMAGE.h"
//Load an image from a file
bool IMAGE::LoadAlpha(const IMAGE & alphaImage)
{
//Cannot load alpha channel into a paletted image
if(paletted)
{
printf("Cannot load alpha channel into a paletted image\n");
return false;
}
//Check alpha image is paletted
if(!alphaImage.paletted)
{
printf("Alpha image is non-paletted\n");
return false;
}
//Check the images are the same size
if(alphaImage.width!=width || alphaImage.height!=height)
{
printf("Alpha image is not the same size as color image\n");
return false;
}
//Create space for new data
int newStride=CalculateStride(32);
GLubyte * tempData=new GLubyte[newStride*height];
if(!tempData)
{
printf("Unable to allocate memory for temporary image data\n");
return false;
}
//Fill in the temporary data
for(unsigned int row=0; row<height; ++row)
{
for(unsigned int i=0; i<width; ++i)
{
tempData[(row*newStride)+i*4+0]=data[(row*stride)+i*bpp/8+0];
tempData[(row*newStride)+i*4+1]=data[(row*stride)+i*bpp/8+1];
tempData[(row*newStride)+i*4+2]=data[(row*stride)+i*bpp/8+2];
tempData[(row*newStride)+i*4+3]=alphaImage.data[(row*alphaImage.stride)+i];
}
}
//delete the old data and swap pointers
if(data)
delete [] data;
data=tempData;
//update bpp and format
bpp=32;
format=GL_RGBA;
return true;
}
-59
View File
@@ -1,59 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////////
// IMAGE_LoadBMP.cpp
// Calculate what type of BMP we are trying to load
// Downloaded from: www.paulsprojects.net
// Created: 9th November 2002
//
// Copyright (c) 2006, Paul Baker
// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
// http://www.paulsprojects.net/NewBSDLicense.txt)
//////////////////////////////////////////////////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <GL/gl.h>
#include "IMAGE.h"
//Open a BMP and find out what type it is
bool IMAGE::LoadBMP(char * filename)
{
FILE * file;
BITMAPFILEHEADER fileHeader;
BITMAPINFOHEADER infoHeader;
//Open file for reading
file=fopen(filename, "rb");
if(!file)
{
printf("Unable to open %s\n", filename);
return false;
}
//read the file header
fread(&fileHeader, sizeof(BITMAPFILEHEADER), 1, file);
//Check this is a bitmap
if(fileHeader.bfType != bitmapID)
{
fclose(file);
printf("%s is not a legal .bmp\n", filename);
return false;
}
//Read in the information header
fread(&infoHeader, sizeof(BITMAPINFOHEADER), 1, file);
//close the file
fclose(file);
//Find out the bpp and go to correct loading function
if(infoHeader.biBitCount==8)
return Load8BitBMP(filename);
if(infoHeader.biBitCount==24)
return Load24BitBMP(filename);
printf("%s has an unsupported bpp\n", filename);
return false;
}
@@ -1,183 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////////
// IMAGE_LoadCompressedTrueColorTGA.cpp
// Load a compressed true color TGA (24 or 32 bit)
// Downloaded from: www.paulsprojects.net
// Created: 16th November 2002
//
// Copyright (c) 2006, Paul Baker
// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
// http://www.paulsprojects.net/NewBSDLicense.txt)
//////////////////////////////////////////////////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <GL/gl.h>
#include "IMAGE.h"
//Load an compressed true color TGA (24 or 32 bit)
bool IMAGE::LoadCompressedTrueColorTGA(char * filename)
{
unsigned char compTGAHeader[12]={0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0};
unsigned char TGAcompare[12];
unsigned char header[6];
printf("Loading %s in LoadCompressedTGA\n", filename);
FILE * file=fopen(filename, "rb");
if(!file)
{
printf("Unable to open %s\n", filename);
return false;
}
//read the "compare" header
fread(TGAcompare, 1, sizeof(TGAcompare), file);
if(memcmp(compTGAHeader, TGAcompare, sizeof(compTGAHeader))!=0)
{
printf("%s is not an uncompressed true color TGA\n", filename);
return false;
}
//read in header
fread(header, 1, sizeof(header), file);
//Save data into class member variables
width= header[1]*256+header[0];
height= header[3]*256+header[2];
bpp= header[4];
if(width<=0 || height<=0 || (bpp!=24 && bpp!=32))
{
fclose(file);
printf("%s's height or width is less than zero, or the TGA is not 24/32 bpp\n", filename);
return false;
}
//Set format
if(bpp==24)
format=GL_RGB;
if(bpp==32)
format=GL_RGBA;
//allocate space for temporary data storage
GLubyte * tempData=new GLubyte[width*height*bpp/8];
if(!tempData)
{
printf("unable to allocate memory for temporary image data\n");
fclose(file);
return false;
}
//read in the image data
int pixelCount=width*height;
int currentPixel=0;
int currentByte=0;
unsigned char * colorBuffer=new unsigned char[bpp/8];
do
{
unsigned char chunkHeader=0;
if(fread(&chunkHeader, sizeof(unsigned char), 1, file)==0)
{
printf("could not read RLE chunk header\n");
fclose(file);
return false;
}
if(chunkHeader<128) //read raw colour values
{
++chunkHeader;
for(int counter=0; counter<chunkHeader; ++counter)
{
if(fread(colorBuffer, 1, bpp/8, file) != bpp/8)
{
printf("unable to read image data\n");
fclose(file);
return false;
}
//transfer pixel colour to data(swapping R and B values)
tempData[currentByte+0]=colorBuffer[2];
tempData[currentByte+1]=colorBuffer[1];
tempData[currentByte+2]=colorBuffer[0];
if(bpp/8==4)
tempData[currentByte+3]=colorBuffer[3];
currentByte+=bpp/8;
++currentPixel;
if(currentPixel>pixelCount)
{
printf("too many pixels read\n");
fclose(file);
return false;
}
}
}
else //chunkHeader>=128
{
chunkHeader-=127;
if(fread(colorBuffer, 1, bpp/8, file) != bpp/8)
{
printf("unable to read image data\n");
fclose(file);
return false;
}
for(int counter=0; counter<chunkHeader; ++counter)
{
//transfer pixel colour to data(swapping R and B values)
tempData[currentByte+0]=colorBuffer[2];
tempData[currentByte+1]=colorBuffer[1];
tempData[currentByte+2]=colorBuffer[0];
if(bpp/8==4)
tempData[currentByte+3]=colorBuffer[3];
currentByte+=bpp/8;
++currentPixel;
if(currentPixel>pixelCount)
{
printf("too many pixels read\n");
fclose(file);
return false;
}
}
}
}while(currentPixel<pixelCount);
//Calculate the stride in bytes for each row (allow for 4-byte padding)
stride=CalculateStride();
//Allocate space for the image data
data=new GLubyte[stride*height];
if(!data)
{
printf( "Unable to allocate data for %s of size %d x %d\n", filename,
stride, height);
return false;
}
//copy in the data a line at a time, hence making it 32-byte aligned
for(unsigned int row=0; row<height; ++row)
{
memcpy(&data[(row*stride)], &tempData[row*width*bpp/8], width*bpp/8);
}
//delete the temporary data
if(tempData)
delete [] tempData;
tempData=NULL;
if(colorBuffer)
delete [] colorBuffer;
colorBuffer=NULL;
printf("Loaded %s Correctly!\n", filename);
return true;
}
-60
View File
@@ -1,60 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////////
// IMAGE_LoadTGA.cpp
// Calculate what type of TGA we are trying to load
// Downloaded from: www.paulsprojects.net
// Created: 16th November 2002
//
// Copyright (c) 2006, Paul Baker
// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
// http://www.paulsprojects.net/NewBSDLicense.txt)
//////////////////////////////////////////////////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <GL/gl.h>
#include "IMAGE.h"
//Open a TGA and find out what type it is
bool IMAGE::LoadTGA(char * filename)
{
unsigned char uncompTGAHeader[12] ={0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
unsigned char compTGAHeader[12] ={0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0};
unsigned char uncomp8Bit24TGAHeader[12] ={0, 1, 1, 0, 0, 0, 1, 24, 0, 0, 0, 0};
unsigned char uncomp8Bit32TGAHeader[12] ={0, 1, 1, 0, 0, 0, 1, 32, 0, 0, 0, 0};
unsigned char TGAcompare[12];
FILE * file;
//Open file for reading
file=fopen(filename, "rb");
if(!file)
{
printf("Unable to open %s\n", filename);
return false;
}
//read the file header
fread(TGAcompare, sizeof(TGAcompare), 1, file);
//close the file
fclose(file);
//Find out the type and go to correct loading function
if(memcmp(uncompTGAHeader, TGAcompare, sizeof(uncompTGAHeader))==0)
return LoadUncompressedTrueColorTGA(filename);
if(memcmp(compTGAHeader, TGAcompare, sizeof(compTGAHeader))==0)
return LoadCompressedTrueColorTGA(filename);
if( memcmp(uncomp8Bit24TGAHeader, TGAcompare, sizeof(uncomp8Bit24TGAHeader))==0 ||
memcmp(uncomp8Bit32TGAHeader, TGAcompare, sizeof(uncomp8Bit32TGAHeader))==0)
{
return LoadUncompressed8BitTGA(filename);
}
printf("%s has an unsupported bpp\n", filename);
return false;
}
@@ -1,114 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////////
// IMAGE_LoadUncompressed8BitTGA.cpp
// Load an uncompressed 8 Bit TGA
// Downloaded from: www.paulsprojects.net
// Created: 16th November 2002
//
// Copyright (c) 2006, Paul Baker
// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
// http://www.paulsprojects.net/NewBSDLicense.txt)
//////////////////////////////////////////////////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <GL/gl.h>
#include "IMAGE.h"
//Load an uncompressed 8 Bit TGA (24 or 32 bit)
bool IMAGE::LoadUncompressed8BitTGA(char * filename)
{
unsigned char uncomp8Bit24TGAHeader[12]={0, 1, 1, 0, 0, 0, 1, 24, 0, 0, 0, 0};
unsigned char uncomp8Bit32TGAHeader[12]={0, 1, 1, 0, 0, 0, 1, 32, 0, 0, 0, 0};
unsigned char TGAcompare[12];
unsigned char header[6];
printf("Loading %s in LoadUncompressed8BitTGA\n", filename);
FILE * file=fopen(filename, "rb");
if(!file)
{
printf("Unable to open %s\n", filename);
return false;
}
//read the "compare" header
fread(TGAcompare, 1, sizeof(TGAcompare), file);
if( memcmp(uncomp8Bit24TGAHeader, TGAcompare, sizeof(uncomp8Bit24TGAHeader))!=0 &&
memcmp(uncomp8Bit32TGAHeader, TGAcompare, sizeof(uncomp8Bit32TGAHeader))!=0)
{
printf("%s is not an uncompressed 8Bit TGA\n", filename);
return false;
}
//read in header
fread(header, 1, sizeof(header), file);
//Save data into class member variables
width= header[1]*256+header[0];
height= header[3]*256+header[2];
bpp= header[4];
if(width<=0 || height<=0 || bpp!=8)
{
fclose(file);
printf("%s's height or width is less than zero, or the TGA is not 8 bpp\n", filename);
return false;
}
paletted=true;
paletteBpp=TGAcompare[7];
if(paletteBpp==24)
paletteFormat=GL_RGB;
if(paletteBpp==32)
paletteFormat=GL_RGBA;
//make space for palette
palette=new GLubyte[256*paletteBpp/8];
if(!palette)
{
fclose(file);
printf("unable to allocate memory for palette\n");
return false;
}
//load in the palette
fread(palette, 256*paletteBpp/8, 1, file);
//Palette is in BGR format
//swap b and r
for(int i=0; i<256; ++i)
{
//Repeated XOR to swap bytes 0 and 2
palette[i*(paletteBpp/8)] ^= palette[i*(paletteBpp/8)+2] ^=
palette[i*(paletteBpp/8)] ^= palette[i*(paletteBpp/8)+2];
}
//Set format
format=GL_COLOR_INDEX;
//Calculate the stride in bytes for each row (allow for 4-byte padding)
stride=CalculateStride();
//Allocate space for the image data
data=new GLubyte[stride*height];
if(!data)
{
fclose(file);
printf( "Unable to allocate data for %s of size %d x %d\n", filename,
stride, height);
return false;
}
//read in the data a line at a time, and save it into the array,
//hence making it 32-byte aligned
for(unsigned int row=0; row<height; ++row)
{
fread(&data[row*stride], 1, width, file);
}
fclose(file);
printf("Loaded %s Correctly!\n", filename);
return true;
}
@@ -1,99 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////////
// IMAGE_LoadUncompressedTrueColorTGA.cpp
// Load an uncompressed true color TGA (24 or 32 bit)
// Downloaded from: www.paulsprojects.net
// Created: 16th November 2002
//
// Copyright (c) 2006, Paul Baker
// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
// http://www.paulsprojects.net/NewBSDLicense.txt)
//////////////////////////////////////////////////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <GL/gl.h>
#include "IMAGE.h"
//Load an uncompressed true color TGA (24 or 32 bit)
bool IMAGE::LoadUncompressedTrueColorTGA(char * filename)
{
unsigned char uncompTGAHeader[12]={0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
unsigned char TGAcompare[12];
unsigned char header[6];
printf("Loading %s in LoadUncompressedTGA\n", filename);
FILE * file=fopen(filename, "rb");
if(!file)
{
printf("Unable to open %s\n", filename);
return false;
}
//read the "compare" header
fread(TGAcompare, 1, sizeof(TGAcompare), file);
if(memcmp(uncompTGAHeader, TGAcompare, sizeof(uncompTGAHeader))!=0)
{
printf("%s is not an uncompressed true color TGA\n", filename);
return false;
}
//read in header
fread(header, 1, sizeof(header), file);
//Save data into class member variables
width= header[1]*256+header[0];
height= header[3]*256+header[2];
bpp= header[4];
if(width<=0 || height<=0 || (bpp!=24 && bpp!=32))
{
fclose(file);
printf("%s's height or width is less than zero, or the TGA is not 24/32 bpp\n", filename);
return false;
}
//Set format
if(bpp==24)
format=GL_RGB;
if(bpp==32)
format=GL_RGBA;
//Calculate the stride in bytes for each row (allow for 4-byte padding)
stride=CalculateStride();
//Allocate space for the image data
data=new GLubyte[stride*height];
if(!data)
{
fclose(file);
printf( "Unable to allocate data for %s of size %d x %d\n", filename,
stride, height);
return false;
}
//read in the data a line at a time, and save it into the array,
//hence making it 32-byte aligned
for(unsigned int row=0; row<height; ++row)
{
fread(&data[row*stride], 1, width*(bpp/8), file);
}
fclose(file);
//Data is in BGR format
//swap b and r
for(unsigned int row=0; row<height; ++row)
{
for(unsigned int i=0; i<width; ++i)
{
//Repeated XOR to swap bytes 0 and 2
data[(row*stride)+i*(bpp/8)] ^= data[(row*stride)+i*(bpp/8)+2] ^=
data[(row*stride)+i*(bpp/8)] ^= data[(row*stride)+i*(bpp/8)+2];
}
}
printf("Loaded %s Correctly!\n", filename);
return true;
}
-98
View File
@@ -1,98 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////////
// TORUS.cpp
// functions for torus with tangents etc
// Downloaded from: www.paulsprojects.net
// Created: 20th July 2002
//
// Copyright (c) 2006, Paul Baker
// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
// http://www.paulsprojects.net/NewBSDLicense.txt)
//////////////////////////////////////////////////////////////////////////////////////////
#include <glb_local.h>
#include <windows.h>
#include <stdio.h>
#include <GL\gl.h>
#include "TORUS.h"
TORUS::TORUS()
{
InitTorus();
}
TORUS::~TORUS()
{
if(indices)
delete [] indices;
indices=NULL;
if(vertices)
delete [] vertices;
vertices=NULL;
}
bool TORUS::InitTorus()
{
numVertices=(torusPrecision+1)*(torusPrecision+1);
numIndices=2*torusPrecision*torusPrecision*3;
vertices=new TORUS_VERTEX[numVertices];
if(!vertices)
{
printf("Unable to allocate memory for torus vertices\n");
return false;
}
indices=new unsigned int[numIndices];
if(!indices)
{
printf("Unable to allocate memory for torus indices\n");
return false;
}
//calculate the first ring - inner radius 4, outer radius 1.5
for(int i=0; i<torusPrecision+1; i++)
{
vertices[i].position=Vector(150.0f, 0.0f, 0.0f).GetRotatedZ(i*360.0f/torusPrecision)+
Vector(400.0f, 0.0f, 0.0f);
vertices[i].s=0.0f;
vertices[i].t=(float)i/torusPrecision;
vertices[i].sTangent = Vector( 0.0f, 0.0f, -1.0f );
vertices[i].tTangent=Vector(0.0f, -1.0f, 0.0f).GetRotatedZ(i*360.0f/torusPrecision);
vertices[i].normal=vertices[i].tTangent.
CrossProduct( vertices[ i ].tTangent, vertices[ i ].sTangent );
}
//rotate this to get other rings
for(int ring=1; ring<torusPrecision+1; ring++)
{
for(int i=0; i<torusPrecision+1; i++)
{
vertices[ring*(torusPrecision+1)+i].position=vertices[i].position.GetRotatedY(ring*360.0f/torusPrecision);
vertices[ring*(torusPrecision+1)+i].s=2.0f*ring/torusPrecision;
vertices[ring*(torusPrecision+1)+i].t=vertices[i].t;
vertices[ring*(torusPrecision+1)+i].sTangent=vertices[i].sTangent.GetRotatedY(ring*360.0f/torusPrecision);
vertices[ring*(torusPrecision+1)+i].tTangent=vertices[i].tTangent.GetRotatedY(ring*360.0f/torusPrecision);
vertices[ring*(torusPrecision+1)+i].normal=vertices[i].normal.GetRotatedY(ring*360.0f/torusPrecision);
}
}
//calculate the indices
for(int ring=0; ring<torusPrecision; ring++)
{
for(int i=0; i<torusPrecision; i++)
{
indices[((ring*torusPrecision+i)*2)*3+0]=ring*(torusPrecision+1)+i;
indices[((ring*torusPrecision+i)*2)*3+1]=(ring+1)*(torusPrecision+1)+i;
indices[((ring*torusPrecision+i)*2)*3+2]=ring*(torusPrecision+1)+i+1;
indices[((ring*torusPrecision+i)*2+1)*3+0]=ring*(torusPrecision+1)+i+1;
indices[((ring*torusPrecision+i)*2+1)*3+1]=(ring+1)*(torusPrecision+1)+i;
indices[((ring*torusPrecision+i)*2+1)*3+2]=(ring+1)*(torusPrecision+1)+i+1;
}
}
return true;
}
-42
View File
@@ -1,42 +0,0 @@
//////////////////////////////////////////////////////////////////////////////////////////
// TORUS.h
// class declaration to create torus with tangents
// Downloaded from: www.paulsprojects.net
// Created: 20th July 2002
//
// Copyright (c) 2006, Paul Baker
// Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
// http://www.paulsprojects.net/NewBSDLicense.txt)
//////////////////////////////////////////////////////////////////////////////////////////
#ifndef TORUS_H
#define TORUS_H
class TORUS_VERTEX
{
public:
Vector position;
float s, t;
Vector sTangent, tTangent;
Vector normal;
Vector tangentSpaceLight;
};
class TORUS
{
public:
TORUS();
~TORUS();
bool InitTorus();
int numVertices;
int numIndices;
unsigned int * indices;
TORUS_VERTEX * vertices;
};
const int torusPrecision=48;
#endif //TORUS_H
-46
View File
@@ -1,46 +0,0 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code 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.
OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// game.cpp : TU Level.
#include "level.h"
Level level;
void Level::setTime( int levelTime )
{
svsTime = levelTime;
inttime = levelTime - svsStartTime;
svsFloatTime = levelTime / 1000.0f;
time = inttime / 1000.0f;
}
void Level::setFrametime( int frametime )
{
intframetime = frametime;
this->frametime = frametime / 1000.0f;
}
CLASS_DECLARATION( Listener, Level, NULL )
{
{ NULL, NULL }
};
-70
View File
@@ -1,70 +0,0 @@
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team
This file is part of OpenMoHAA source code.
OpenMoHAA source code 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.
OpenMoHAA source code 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 OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// level.h : TU Level.
#ifndef __LEVEL_H__
#define __LEVEL_H__
#include <listener.h>
class SimpleArchivedEntity;
class Level : public Listener {
public:
bool m_LoopDrop;
bool m_LoopProtection;
str m_mapscript;
str current_map;
// Level time
int framenum;
int inttime;
int intframetime;
float time;
float frametime;
int spawnflags;
// Server time
int svsTime;
float svsFloatTime;
int svsStartTime;
int svsEndTime;
bool m_bScriptSpawn;
bool m_bRejectSpawn;
Container< SimpleArchivedEntity * > m_SimpleArchivedEntities;
public:
CLASS_PROTOTYPE( Level );
void setTime( int _svsTime_ );
void setFrametime( int frameTime );
};
extern Level level;
#endif /* __LEVEL_H__*/
File diff suppressed because it is too large. Load diff
-51
View File
@@ -1,51 +0,0 @@
/*
* Game-Deception Blank Wrapper v2
* Copyright (c) Crusader 2002
*/
/*
* Useful ogl functions for half-life including hooked extensions
*/
#include "opengl_api.h"
/*
#pragma warning(disable:4100)
BOOL __stdcall DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
{
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls (hOpenGL);
return Init();
case DLL_PROCESS_DETACH:
if ( hOpenGL != NULL )
{
FreeLibrary(hOpenGL);
hOpenGL = NULL;
}
break;
}
return TRUE;
}
#pragma warning(default:4100)
*/
void __cdecl add_log (const char * fmt, ...)
{
va_list va_alist;
char logbuf[256] = "";
FILE * fp;
va_start (va_alist, fmt);
_vsnprintf (logbuf+strlen(logbuf), sizeof(logbuf) - strlen(logbuf), fmt, va_alist);
va_end (va_alist);
if ( (fp = fopen ("opengl32.log", "ab")) != NULL )
{
fprintf ( fp, "%s\n", logbuf );
fclose (fp);
}
}
-790
View File
@@ -1,790 +0,0 @@
/*
* Game-Deception Blank Wrapper v2
* Copyright (c) Crusader 2002
*/
#ifndef H_OPENGL32
#define H_OPENGL32
#define ORIGINAL_DLL "opengl32.dll"
/* Original function typedefs */
#include <windows.h>
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include <gl/gl.h>
#include <gl/glu.h>
//#include <gl/glaux.h>
#include <math.h>
#define WANT_OPENGL
#include "cgamex86.h"
#ifdef __cplusplus
extern "C" {
#endif
#define GL_NORMAL_MAP_ARB 0x8511
#define GL_REFLECTION_MAP_ARB 0x8512
#define GL_TEXTURE_CUBE_MAP_ARB 0x8513
#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A
#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B
#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C
//#define GL_TEXTURE_WRAP_R 0x2804
#define GL_CLAMP_TO_EDGE 0x812F
extern BOOL glInit (void);
//extern void __cdecl add_log ( const char * fmt, ... );
extern HMODULE hOpenGL;
typedef void ( WINAPI *func_glActiveTextureARB_t) (GLenum target);
typedef void ( WINAPI *func_BindTextureEXT_t) (GLenum target, GLuint texture);
typedef void ( WINAPI *func_glMultiTexCoord2fARB_t) (GLenum target, GLfloat s, GLfloat t);
typedef void ( WINAPI *func_glAccum_t) (GLenum op, GLfloat value);
typedef void ( WINAPI *func_glAlphaFunc_t) (GLenum func, GLclampf ref);
typedef GLboolean ( WINAPI *func_glAreTexturesResident_t) (GLsizei n, const GLuint *textures, GLboolean *residences);
typedef void ( WINAPI *func_glArrayElement_t) (GLint i);
typedef void ( WINAPI *func_glBegin_t) (GLenum mode);
typedef void ( WINAPI *func_glBindTexture_t) (GLenum target, GLuint texture);
typedef void ( WINAPI *func_glBitmap_t) (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);
typedef void ( WINAPI *func_glBlendFunc_t) (GLenum sfactor, GLenum dfactor);
typedef void ( WINAPI *func_glCallList_t) (GLuint list);
typedef void ( WINAPI *func_glCallLists_t) (GLsizei n, GLenum type, const GLvoid *lists);
typedef void ( WINAPI *func_glClear_t) (GLbitfield mask);
typedef void ( WINAPI *func_glClearAccum_t) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
typedef void ( WINAPI *func_glClearColor_t) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
typedef void ( WINAPI *func_glClearDepth_t) (GLclampd depth);
typedef void ( WINAPI *func_glClearIndex_t) (GLfloat c);
typedef void ( WINAPI *func_glClearStencil_t) (GLint s);
typedef void ( WINAPI *func_glClipPlane_t) (GLenum plane, const GLdouble *equation);
typedef void ( WINAPI *func_glColor3b_t) (GLbyte red, GLbyte green, GLbyte blue);
typedef void ( WINAPI *func_glColor3bv_t) (const GLbyte *v);
typedef void ( WINAPI *func_glColor3d_t) (GLdouble red, GLdouble green, GLdouble blue);
typedef void ( WINAPI *func_glColor3dv_t) (const GLdouble *v);
typedef void ( WINAPI *func_glColor3f_t) (GLfloat red, GLfloat green, GLfloat blue);
typedef void ( WINAPI *func_glColor3fv_t) (const GLfloat *v);
typedef void ( WINAPI *func_glColor3i_t) (GLint red, GLint green, GLint blue);
typedef void ( WINAPI *func_glColor3iv_t) (const GLint *v);
typedef void ( WINAPI *func_glColor3s_t) (GLshort red, GLshort green, GLshort blue);
typedef void ( WINAPI *func_glColor3sv_t) (const GLshort *v);
typedef void ( WINAPI *func_glColor3ub_t) (GLubyte red, GLubyte green, GLubyte blue);
typedef void ( WINAPI *func_glColor3ubv_t) (const GLubyte *v);
typedef void ( WINAPI *func_glColor3ui_t) (GLuint red, GLuint green, GLuint blue);
typedef void ( WINAPI *func_glColor3uiv_t) (const GLuint *v);
typedef void ( WINAPI *func_glColor3us_t) (GLushort red, GLushort green, GLushort blue);
typedef void ( WINAPI *func_glColor3usv_t) (const GLushort *v);
typedef void ( WINAPI *func_glColor4b_t) (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);
typedef void ( WINAPI *func_glColor4bv_t) (const GLbyte *v);
typedef void ( WINAPI *func_glColor4d_t) (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);
typedef void ( WINAPI *func_glColor4dv_t) (const GLdouble *v);
typedef void ( WINAPI *func_glColor4f_t) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
typedef void ( WINAPI *func_glColor4fv_t) (const GLfloat *v);
typedef void ( WINAPI *func_glColor4i_t) (GLint red, GLint green, GLint blue, GLint alpha);
typedef void ( WINAPI *func_glColor4iv_t) (const GLint *v);
typedef void ( WINAPI *func_glColor4s_t) (GLshort red, GLshort green, GLshort blue, GLshort alpha);
typedef void ( WINAPI *func_glColor4sv_t) (const GLshort *v);
typedef void ( WINAPI *func_glColor4ub_t) (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
typedef void ( WINAPI *func_glColor4ubv_t) (const GLubyte *v);
typedef void ( WINAPI *func_glColor4ui_t) (GLuint red, GLuint green, GLuint blue, GLuint alpha);
typedef void ( WINAPI *func_glColor4uiv_t) (const GLuint *v);
typedef void ( WINAPI *func_glColor4us_t) (GLushort red, GLushort green, GLushort blue, GLushort alpha);
typedef void ( WINAPI *func_glColor4usv_t) (const GLushort *v);
typedef void ( WINAPI *func_glColorMask_t) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
typedef void ( WINAPI *func_glColorMaterial_t) (GLenum face, GLenum mode);
typedef void ( WINAPI *func_glColorPointer_t) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
typedef void ( WINAPI *func_glCopyPixels_t) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
typedef void ( WINAPI *func_glCopyTexImage1D_t) (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);
typedef void ( WINAPI *func_glCopyTexImage2D_t) (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
typedef void ( WINAPI *func_glCopyTexSubImage1D_t) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
typedef void ( WINAPI *func_glCopyTexSubImage2D_t) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
typedef void ( WINAPI *func_glCullFace_t) (GLenum mode);
typedef void ( WINAPI *func_glDebugEntry_t) (void);
typedef void ( WINAPI *func_glDeleteLists_t) (GLuint list, GLsizei range);
typedef void ( WINAPI *func_glDeleteTextures_t) (GLsizei n, const GLuint *textures);
typedef void ( WINAPI *func_glDepthFunc_t) (GLenum func);
typedef void ( WINAPI *func_glDepthMask_t) (GLboolean flag);
typedef void ( WINAPI *func_glDepthRange_t) (GLclampd zNear, GLclampd zFar);
typedef void ( WINAPI *func_glDisable_t) (GLenum cap);
typedef void ( WINAPI *func_glDisableClientState_t) (GLenum array);
typedef void ( WINAPI *func_glDrawArrays_t) (GLenum mode, GLint first, GLsizei count);
typedef void ( WINAPI *func_glDrawBuffer_t) (GLenum mode);
typedef void ( WINAPI *func_glDrawElements_t) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
typedef void ( WINAPI *func_glDrawPixels_t) (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
typedef void ( WINAPI *func_glEdgeFlag_t) (GLboolean flag);
typedef void ( WINAPI *func_glEdgeFlagPointer_t) (GLsizei stride, const GLvoid *pointer);
typedef void ( WINAPI *func_glEdgeFlagv_t) (const GLboolean *flag);
typedef void ( WINAPI *func_glEnable_t) (GLenum cap);
typedef void ( WINAPI *func_glEnableClientState_t) (GLenum array);
typedef void ( WINAPI *func_glEnd_t) (void);
typedef void ( WINAPI *func_glEndList_t) (void);
typedef void ( WINAPI *func_glEvalCoord1d_t) (GLdouble u);
typedef void ( WINAPI *func_glEvalCoord1dv_t) (const GLdouble *u);
typedef void ( WINAPI *func_glEvalCoord1f_t) (GLfloat u);
typedef void ( WINAPI *func_glEvalCoord1fv_t) (const GLfloat *u);
typedef void ( WINAPI *func_glEvalCoord2d_t) (GLdouble u, GLdouble v);
typedef void ( WINAPI *func_glEvalCoord2dv_t) (const GLdouble *u);
typedef void ( WINAPI *func_glEvalCoord2f_t) (GLfloat u, GLfloat v);
typedef void ( WINAPI *func_glEvalCoord2fv_t) (const GLfloat *u);
typedef void ( WINAPI *func_glEvalMesh1_t) (GLenum mode, GLint i1, GLint i2);
typedef void ( WINAPI *func_glEvalMesh2_t) (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);
typedef void ( WINAPI *func_glEvalPoint1_t) (GLint i);
typedef void ( WINAPI *func_glEvalPoint2_t) (GLint i, GLint j);
typedef void ( WINAPI *func_glFeedbackBuffer_t) (GLsizei size, GLenum type, GLfloat *buffer);
typedef void ( WINAPI *func_glFinish_t) (void);
typedef void ( WINAPI *func_glFlush_t) (void);
typedef void ( WINAPI *func_glFogf_t) (GLenum pname, GLfloat param);
typedef void ( WINAPI *func_glFogfv_t) (GLenum pname, const GLfloat *params);
typedef void ( WINAPI *func_glFogi_t) (GLenum pname, GLint param);
typedef void ( WINAPI *func_glFogiv_t) (GLenum pname, const GLint *params);
typedef void ( WINAPI *func_glFrontFace_t) (GLenum mode);
typedef void ( WINAPI *func_glFrustum_t) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
typedef GLuint ( WINAPI *func_glGenLists_t) (GLsizei range);
typedef void ( WINAPI *func_glGenTextures_t) (GLsizei n, GLuint *textures);
typedef void ( WINAPI *func_glGetBooleanv_t) (GLenum pname, GLboolean *params);
typedef void ( WINAPI *func_glGetClipPlane_t) (GLenum plane, GLdouble *equation);
typedef void ( WINAPI *func_glGetDoublev_t) (GLenum pname, GLdouble *params);
typedef GLenum ( WINAPI *func_glGetError_t) (void);
typedef void ( WINAPI *func_glGetFloatv_t) (GLenum pname, GLfloat *params);
typedef void ( WINAPI *func_glGetIntegerv_t) (GLenum pname, GLint *params);
typedef void ( WINAPI *func_glGetLightfv_t) (GLenum light, GLenum pname, GLfloat *params);
typedef void ( WINAPI *func_glGetLightiv_t) (GLenum light, GLenum pname, GLint *params);
typedef void ( WINAPI *func_glGetMapdv_t) (GLenum target, GLenum query, GLdouble *v);
typedef void ( WINAPI *func_glGetMapfv_t) (GLenum target, GLenum query, GLfloat *v);
typedef void ( WINAPI *func_glGetMapiv_t) (GLenum target, GLenum query, GLint *v);
typedef void ( WINAPI *func_glGetMaterialfv_t) (GLenum face, GLenum pname, GLfloat *params);
typedef void ( WINAPI *func_glGetMaterialiv_t) (GLenum face, GLenum pname, GLint *params);
typedef void ( WINAPI *func_glGetPixelMapfv_t) (GLenum map, GLfloat *values);
typedef void ( WINAPI *func_glGetPixelMapuiv_t) (GLenum map, GLuint *values);
typedef void ( WINAPI *func_glGetPixelMapusv_t) (GLenum map, GLushort *values);
typedef void ( WINAPI *func_glGetPointerv_t) (GLenum pname, GLvoid* *params);
typedef void ( WINAPI *func_glGetPolygonStipple_t) (GLubyte *mask);
typedef const GLubyte * ( WINAPI *func_glGetString_t) (GLenum name);
typedef void ( WINAPI *func_glGetTexEnvfv_t) (GLenum target, GLenum pname, GLfloat *params);
typedef void ( WINAPI *func_glGetTexEnviv_t) (GLenum target, GLenum pname, GLint *params);
typedef void ( WINAPI *func_glGetTexGendv_t) (GLenum coord, GLenum pname, GLdouble *params);
typedef void ( WINAPI *func_glGetTexGenfv_t) (GLenum coord, GLenum pname, GLfloat *params);
typedef void ( WINAPI *func_glGetTexGeniv_t) (GLenum coord, GLenum pname, GLint *params);
typedef void ( WINAPI *func_glGetTexImage_t) (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
typedef void ( WINAPI *func_glGetTexLevelParameterfv_t) (GLenum target, GLint level, GLenum pname, GLfloat *params);
typedef void ( WINAPI *func_glGetTexLevelParameteriv_t) (GLenum target, GLint level, GLenum pname, GLint *params);
typedef void ( WINAPI *func_glGetTexParameterfv_t) (GLenum target, GLenum pname, GLfloat *params);
typedef void ( WINAPI *func_glGetTexParameteriv_t) (GLenum target, GLenum pname, GLint *params);
typedef void ( WINAPI *func_glHint_t) (GLenum target, GLenum mode);
typedef void ( WINAPI *func_glIndexMask_t) (GLuint mask);
typedef void ( WINAPI *func_glIndexPointer_t) (GLenum type, GLsizei stride, const GLvoid *pointer);
typedef void ( WINAPI *func_glIndexd_t) (GLdouble c);
typedef void ( WINAPI *func_glIndexdv_t) (const GLdouble *c);
typedef void ( WINAPI *func_glIndexf_t) (GLfloat c);
typedef void ( WINAPI *func_glIndexfv_t) (const GLfloat *c);
typedef void ( WINAPI *func_glIndexi_t) (GLint c);
typedef void ( WINAPI *func_glIndexiv_t) (const GLint *c);
typedef void ( WINAPI *func_glIndexs_t) (GLshort c);
typedef void ( WINAPI *func_glIndexsv_t) (const GLshort *c);
typedef void ( WINAPI *func_glIndexub_t) (GLubyte c);
typedef void ( WINAPI *func_glIndexubv_t) (const GLubyte *c);
typedef void ( WINAPI *func_glInitNames_t) (void);
typedef void ( WINAPI *func_glInterleavedArrays_t) (GLenum format, GLsizei stride, const GLvoid *pointer);
typedef GLboolean ( WINAPI *func_glIsEnabled_t) (GLenum cap);
typedef GLboolean ( WINAPI *func_glIsList_t) (GLuint list);
typedef GLboolean ( WINAPI *func_glIsTexture_t) (GLuint texture);
typedef void ( WINAPI *func_glLightModelf_t) (GLenum pname, GLfloat param);
typedef void ( WINAPI *func_glLightModelfv_t) (GLenum pname, const GLfloat *params);
typedef void ( WINAPI *func_glLightModeli_t) (GLenum pname, GLint param);
typedef void ( WINAPI *func_glLightModeliv_t) (GLenum pname, const GLint *params);
typedef void ( WINAPI *func_glLightf_t) (GLenum light, GLenum pname, GLfloat param);
typedef void ( WINAPI *func_glLightfv_t) (GLenum light, GLenum pname, const GLfloat *params);
typedef void ( WINAPI *func_glLighti_t) (GLenum light, GLenum pname, GLint param);
typedef void ( WINAPI *func_glLightiv_t) (GLenum light, GLenum pname, const GLint *params);
typedef void ( WINAPI *func_glLineStipple_t) (GLint factor, GLushort pattern);
typedef void ( WINAPI *func_glLineWidth_t) (GLfloat width);
typedef void ( WINAPI *func_glListBase_t) (GLuint base);
typedef void ( WINAPI *func_glLoadIdentity_t) (void);
typedef void ( WINAPI *func_glLoadMatrixd_t) (const GLdouble *m);
typedef void ( WINAPI *func_glLoadMatrixf_t) (const GLfloat *m);
typedef void ( WINAPI *func_glLoadName_t) (GLuint name);
typedef void ( WINAPI *func_glLogicOp_t) (GLenum opcode);
typedef void ( WINAPI *func_glMap1d_t) (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);
typedef void ( WINAPI *func_glMap1f_t) (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);
typedef void ( WINAPI *func_glMap2d_t) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);
typedef void ( WINAPI *func_glMap2f_t) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);
typedef void ( WINAPI *func_glMapGrid1d_t) (GLint un, GLdouble u1, GLdouble u2);
typedef void ( WINAPI *func_glMapGrid1f_t) (GLint un, GLfloat u1, GLfloat u2);
typedef void ( WINAPI *func_glMapGrid2d_t) (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);
typedef void ( WINAPI *func_glMapGrid2f_t) (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);
typedef void ( WINAPI *func_glMaterialf_t) (GLenum face, GLenum pname, GLfloat param);
typedef void ( WINAPI *func_glMaterialfv_t) (GLenum face, GLenum pname, const GLfloat *params);
typedef void ( WINAPI *func_glMateriali_t) (GLenum face, GLenum pname, GLint param);
typedef void ( WINAPI *func_glMaterialiv_t) (GLenum face, GLenum pname, const GLint *params);
typedef void ( WINAPI *func_glMatrixMode_t) (GLenum mode);
typedef void ( WINAPI *func_glMultMatrixd_t) (const GLdouble *m);
typedef void ( WINAPI *func_glMultMatrixf_t) (const GLfloat *m);
typedef void ( WINAPI *func_glNewList_t) (GLuint list, GLenum mode);
typedef void ( WINAPI *func_glNormal3b_t) (GLbyte nx, GLbyte ny, GLbyte nz);
typedef void ( WINAPI *func_glNormal3bv_t) (const GLbyte *v);
typedef void ( WINAPI *func_glNormal3d_t) (GLdouble nx, GLdouble ny, GLdouble nz);
typedef void ( WINAPI *func_glNormal3dv_t) (const GLdouble *v);
typedef void ( WINAPI *func_glNormal3f_t) (GLfloat nx, GLfloat ny, GLfloat nz);
typedef void ( WINAPI *func_glNormal3fv_t) (const GLfloat *v);
typedef void ( WINAPI *func_glNormal3i_t) (GLint nx, GLint ny, GLint nz);
typedef void ( WINAPI *func_glNormal3iv_t) (const GLint *v);
typedef void ( WINAPI *func_glNormal3s_t) (GLshort nx, GLshort ny, GLshort nz);
typedef void ( WINAPI *func_glNormal3sv_t) (const GLshort *v);
typedef void ( WINAPI *func_glNormalPointer_t) (GLenum type, GLsizei stride, const GLvoid *pointer);
typedef void ( WINAPI *func_glOrtho_t) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
typedef void ( WINAPI *func_glPassThrough_t) (GLfloat token);
typedef void ( WINAPI *func_glPixelMapfv_t) (GLenum map, GLsizei mapsize, const GLfloat *values);
typedef void ( WINAPI *func_glPixelMapuiv_t) (GLenum map, GLsizei mapsize, const GLuint *values);
typedef void ( WINAPI *func_glPixelMapusv_t) (GLenum map, GLsizei mapsize, const GLushort *values);
typedef void ( WINAPI *func_glPixelStoref_t) (GLenum pname, GLfloat param);
typedef void ( WINAPI *func_glPixelStorei_t) (GLenum pname, GLint param);
typedef void ( WINAPI *func_glPixelTransferf_t) (GLenum pname, GLfloat param);
typedef void ( WINAPI *func_glPixelTransferi_t) (GLenum pname, GLint param);
typedef void ( WINAPI *func_glPixelZoom_t) (GLfloat xfactor, GLfloat yfactor);
typedef void ( WINAPI *func_glPointSize_t) (GLfloat size);
typedef void ( WINAPI *func_glPolygonMode_t) (GLenum face, GLenum mode);
typedef void ( WINAPI *func_glPolygonOffset_t) (GLfloat factor, GLfloat units);
typedef void ( WINAPI *func_glPolygonStipple_t) (const GLubyte *mask);
typedef void ( WINAPI *func_glPopAttrib_t) (void);
typedef void ( WINAPI *func_glPopClientAttrib_t) (void);
typedef void ( WINAPI *func_glPopMatrix_t) (void);
typedef void ( WINAPI *func_glPopName_t) (void);
typedef void ( WINAPI *func_glPrioritizeTextures_t) (GLsizei n, const GLuint *textures, const GLclampf *priorities);
typedef void ( WINAPI *func_glPushAttrib_t) (GLbitfield mask);
typedef void ( WINAPI *func_glPushClientAttrib_t) (GLbitfield mask);
typedef void ( WINAPI *func_glPushMatrix_t) (void);
typedef void ( WINAPI *func_glPushName_t) (GLuint name);
typedef void ( WINAPI *func_glRasterPos2d_t) (GLdouble x, GLdouble y);
typedef void ( WINAPI *func_glRasterPos2dv_t) (const GLdouble *v);
typedef void ( WINAPI *func_glRasterPos2f_t) (GLfloat x, GLfloat y);
typedef void ( WINAPI *func_glRasterPos2fv_t) (const GLfloat *v);
typedef void ( WINAPI *func_glRasterPos2i_t) (GLint x, GLint y);
typedef void ( WINAPI *func_glRasterPos2iv_t) (const GLint *v);
typedef void ( WINAPI *func_glRasterPos2s_t) (GLshort x, GLshort y);
typedef void ( WINAPI *func_glRasterPos2sv_t) (const GLshort *v);
typedef void ( WINAPI *func_glRasterPos3d_t) (GLdouble x, GLdouble y, GLdouble z);
typedef void ( WINAPI *func_glRasterPos3dv_t) (const GLdouble *v);
typedef void ( WINAPI *func_glRasterPos3f_t) (GLfloat x, GLfloat y, GLfloat z);
typedef void ( WINAPI *func_glRasterPos3fv_t) (const GLfloat *v);
typedef void ( WINAPI *func_glRasterPos3i_t) (GLint x, GLint y, GLint z);
typedef void ( WINAPI *func_glRasterPos3iv_t) (const GLint *v);
typedef void ( WINAPI *func_glRasterPos3s_t) (GLshort x, GLshort y, GLshort z);
typedef void ( WINAPI *func_glRasterPos3sv_t) (const GLshort *v);
typedef void ( WINAPI *func_glRasterPos4d_t) (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
typedef void ( WINAPI *func_glRasterPos4dv_t) (const GLdouble *v);
typedef void ( WINAPI *func_glRasterPos4f_t) (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
typedef void ( WINAPI *func_glRasterPos4fv_t) (const GLfloat *v);
typedef void ( WINAPI *func_glRasterPos4i_t) (GLint x, GLint y, GLint z, GLint w);
typedef void ( WINAPI *func_glRasterPos4iv_t) (const GLint *v);
typedef void ( WINAPI *func_glRasterPos4s_t) (GLshort x, GLshort y, GLshort z, GLshort w);
typedef void ( WINAPI *func_glRasterPos4sv_t) (const GLshort *v);
typedef void ( WINAPI *func_glReadBuffer_t) (GLenum mode);
typedef void ( WINAPI *func_glReadPixels_t) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
typedef void ( WINAPI *func_glRectd_t) (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);
typedef void ( WINAPI *func_glRectdv_t) (const GLdouble *v1, const GLdouble *v2);
typedef void ( WINAPI *func_glRectf_t) (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
typedef void ( WINAPI *func_glRectfv_t) (const GLfloat *v1, const GLfloat *v2);
typedef void ( WINAPI *func_glRecti_t) (GLint x1, GLint y1, GLint x2, GLint y2);
typedef void ( WINAPI *func_glRectiv_t) (const GLint *v1, const GLint *v2);
typedef void ( WINAPI *func_glRects_t) (GLshort x1, GLshort y1, GLshort x2, GLshort y2);
typedef void ( WINAPI *func_glRectsv_t) (const GLshort *v1, const GLshort *v2);
typedef GLint ( WINAPI *func_glRenderMode_t) (GLenum mode);
typedef void ( WINAPI *func_glRotated_t) (GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
typedef void ( WINAPI *func_glRotatef_t) (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
typedef void ( WINAPI *func_glScaled_t) (GLdouble x, GLdouble y, GLdouble z);
typedef void ( WINAPI *func_glScalef_t) (GLfloat x, GLfloat y, GLfloat z);
typedef void ( WINAPI *func_glScissor_t) (GLint x, GLint y, GLsizei width, GLsizei height);
typedef void ( WINAPI *func_glSelectBuffer_t) (GLsizei size, GLuint *buffer);
typedef void ( WINAPI *func_glShadeModel_t) (GLenum mode);
typedef void ( WINAPI *func_glStencilFunc_t) (GLenum func, GLint ref, GLuint mask);
typedef void ( WINAPI *func_glStencilMask_t) (GLuint mask);
typedef void ( WINAPI *func_glStencilOp_t) (GLenum fail, GLenum zfail, GLenum zpass);
typedef void ( WINAPI *func_glSwapBuffers_t) (void);
typedef void ( WINAPI *func_glTexCoord1d_t) (GLdouble s);
typedef void ( WINAPI *func_glTexCoord1dv_t) (const GLdouble *v);
typedef void ( WINAPI *func_glTexCoord1f_t) (GLfloat s);
typedef void ( WINAPI *func_glTexCoord1fv_t) (const GLfloat *v);
typedef void ( WINAPI *func_glTexCoord1i_t) (GLint s);
typedef void ( WINAPI *func_glTexCoord1iv_t) (const GLint *v);
typedef void ( WINAPI *func_glTexCoord1s_t) (GLshort s);
typedef void ( WINAPI *func_glTexCoord1sv_t) (const GLshort *v);
typedef void ( WINAPI *func_glTexCoord2d_t) (GLdouble s, GLdouble t);
typedef void ( WINAPI *func_glTexCoord2dv_t) (const GLdouble *v);
typedef void ( WINAPI *func_glTexCoord2f_t) (GLfloat s, GLfloat t);
typedef void ( WINAPI *func_glTexCoord2fv_t) (const GLfloat *v);
typedef void ( WINAPI *func_glTexCoord2i_t) (GLint s, GLint t);
typedef void ( WINAPI *func_glTexCoord2iv_t) (const GLint *v);
typedef void ( WINAPI *func_glTexCoord2s_t) (GLshort s, GLshort t);
typedef void ( WINAPI *func_glTexCoord2sv_t) (const GLshort *v);
typedef void ( WINAPI *func_glTexCoord3d_t) (GLdouble s, GLdouble t, GLdouble r);
typedef void ( WINAPI *func_glTexCoord3dv_t) (const GLdouble *v);
typedef void ( WINAPI *func_glTexCoord3f_t) (GLfloat s, GLfloat t, GLfloat r);
typedef void ( WINAPI *func_glTexCoord3fv_t) (const GLfloat *v);
typedef void ( WINAPI *func_glTexCoord3i_t) (GLint s, GLint t, GLint r);
typedef void ( WINAPI *func_glTexCoord3iv_t) (const GLint *v);
typedef void ( WINAPI *func_glTexCoord3s_t) (GLshort s, GLshort t, GLshort r);
typedef void ( WINAPI *func_glTexCoord3sv_t) (const GLshort *v);
typedef void ( WINAPI *func_glTexCoord4d_t) (GLdouble s, GLdouble t, GLdouble r, GLdouble q);
typedef void ( WINAPI *func_glTexCoord4dv_t) (const GLdouble *v);
typedef void ( WINAPI *func_glTexCoord4f_t) (GLfloat s, GLfloat t, GLfloat r, GLfloat q);
typedef void ( WINAPI *func_glTexCoord4fv_t) (const GLfloat *v);
typedef void ( WINAPI *func_glTexCoord4i_t) (GLint s, GLint t, GLint r, GLint q);
typedef void ( WINAPI *func_glTexCoord4iv_t) (const GLint *v);
typedef void ( WINAPI *func_glTexCoord4s_t) (GLshort s, GLshort t, GLshort r, GLshort q);
typedef void ( WINAPI *func_glTexCoord4sv_t) (const GLshort *v);
typedef void ( WINAPI *func_glTexCoordPointer_t) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
typedef void ( WINAPI *func_glTexEnvf_t) (GLenum target, GLenum pname, GLfloat param);
typedef void ( WINAPI *func_glTexEnvfv_t) (GLenum target, GLenum pname, const GLfloat *params);
typedef void ( WINAPI *func_glTexEnvi_t) (GLenum target, GLenum pname, GLint param);
typedef void ( WINAPI *func_glTexEnviv_t) (GLenum target, GLenum pname, const GLint *params);
typedef void ( WINAPI *func_glTexGend_t) (GLenum coord, GLenum pname, GLdouble param);
typedef void ( WINAPI *func_glTexGendv_t) (GLenum coord, GLenum pname, const GLdouble *params);
typedef void ( WINAPI *func_glTexGenf_t) (GLenum coord, GLenum pname, GLfloat param);
typedef void ( WINAPI *func_glTexGenfv_t) (GLenum coord, GLenum pname, const GLfloat *params);
typedef void ( WINAPI *func_glTexGeni_t) (GLenum coord, GLenum pname, GLint param);
typedef void ( WINAPI *func_glTexGeniv_t) (GLenum coord, GLenum pname, const GLint *params);
typedef void ( WINAPI *func_glTexImage1D_t) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
typedef void ( WINAPI *func_glTexImage2D_t) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
typedef void ( WINAPI *func_glTexParameterf_t) (GLenum target, GLenum pname, GLfloat param);
typedef void ( WINAPI *func_glTexParameterfv_t) (GLenum target, GLenum pname, const GLfloat *params);
typedef void ( WINAPI *func_glTexParameteri_t) (GLenum target, GLenum pname, GLint param);
typedef void ( WINAPI *func_glTexParameteriv_t) (GLenum target, GLenum pname, const GLint *params);
typedef void ( WINAPI *func_glTexSubImage1D_t) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
typedef void ( WINAPI *func_glTexSubImage2D_t) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
typedef void ( WINAPI *func_glTranslated_t) (GLdouble x, GLdouble y, GLdouble z);
typedef void ( WINAPI *func_glTranslatef_t) (GLfloat x, GLfloat y, GLfloat z);
typedef void ( WINAPI *func_glVertex2d_t) (GLdouble x, GLdouble y);
typedef void ( WINAPI *func_glVertex2dv_t) (const GLdouble *v);
typedef void ( WINAPI *func_glVertex2f_t) (GLfloat x, GLfloat y);
typedef void ( WINAPI *func_glVertex2fv_t) (const GLfloat *v);
typedef void ( WINAPI *func_glVertex2i_t) (GLint x, GLint y);
typedef void ( WINAPI *func_glVertex2iv_t) (const GLint *v);
typedef void ( WINAPI *func_glVertex2s_t) (GLshort x, GLshort y);
typedef void ( WINAPI *func_glVertex2sv_t) (const GLshort *v);
typedef void ( WINAPI *func_glVertex3d_t) (GLdouble x, GLdouble y, GLdouble z);
typedef void ( WINAPI *func_glVertex3dv_t) (const GLdouble *v);
typedef void ( WINAPI *func_glVertex3f_t) (GLfloat x, GLfloat y, GLfloat z);
typedef void ( WINAPI *func_glVertex3fv_t) (const GLfloat *v);
typedef void ( WINAPI *func_glVertex3i_t) (GLint x, GLint y, GLint z);
typedef void ( WINAPI *func_glVertex3iv_t) (const GLint *v);
typedef void ( WINAPI *func_glVertex3s_t) (GLshort x, GLshort y, GLshort z);
typedef void ( WINAPI *func_glVertex3sv_t) (const GLshort *v);
typedef void ( WINAPI *func_glVertex4d_t) (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
typedef void ( WINAPI *func_glVertex4dv_t) (const GLdouble *v);
typedef void ( WINAPI *func_glVertex4f_t) (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
typedef void ( WINAPI *func_glVertex4fv_t) (const GLfloat *v);
typedef void ( WINAPI *func_glVertex4i_t) (GLint x, GLint y, GLint z, GLint w);
typedef void ( WINAPI *func_glVertex4iv_t) (const GLint *v);
typedef void ( WINAPI *func_glVertex4s_t) (GLshort x, GLshort y, GLshort z, GLshort w);
typedef void ( WINAPI *func_glVertex4sv_t) (const GLshort *v);
typedef void ( WINAPI *func_glVertexPointer_t) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
typedef void ( WINAPI *func_glViewport_t) (GLint x, GLint y, GLsizei width, GLsizei height);
typedef void ( WINAPI *func_wglChoosePixelFormat_t) (void);
typedef void ( WINAPI *func_wglCopyContext_t) (void);
typedef void ( WINAPI *func_wglCreateContext_t) (void);
typedef void ( WINAPI *func_wglCreateLayerContext_t) (void);
typedef void ( WINAPI *func_wglDeleteContext_t) (void);
typedef void ( WINAPI *func_wglDescribeLayerPlane_t) (void);
typedef void ( WINAPI *func_wglDescribePixelFormat_t) (void);
typedef void ( WINAPI *func_wglGetCurrentContext_t) (void);
typedef HDC ( WINAPI *func_wglGetCurrentDC_t) (void);
typedef void ( WINAPI *func_wglGetDefaultProcAddress_t) (void);
typedef void ( WINAPI *func_wglGetLayerPaletteEntries_t) (void);
typedef void ( WINAPI *func_wglGetPixelFormat_t) (void);
typedef PROC ( WINAPI *func_wglGetProcAddress_t) (LPCSTR);
typedef void ( WINAPI *func_wglMakeCurrent_t) (void);
typedef void ( WINAPI *func_wglRealizeLayerPalette_t) (void);
typedef void ( WINAPI *func_wglSetLayerPaletteEntries_t) (void);
typedef void ( WINAPI *func_wglSetPixelFormat_t) (void);
typedef void ( WINAPI *func_wglShareLists_t) (void);
typedef void ( WINAPI *func_wglSwapBuffers_t) (HDC hDC);
typedef void ( WINAPI *func_wglSwapLayerBuffers_t) (void);
typedef void ( WINAPI *func_wglUseFontBitmapsA_t) (HDC, DWORD, DWORD, DWORD);
typedef void ( WINAPI *func_wglUseFontBitmapsW_t) (void);
typedef void ( WINAPI *func_wglUseFontOutlinesA_t) (HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT);
typedef void ( WINAPI *func_wglUseFontOutlinesW_t) (void);
extern func_glActiveTextureARB_t orig_glActiveTextureARB;
extern func_BindTextureEXT_t orig_BindTextureEXT;
extern func_glMultiTexCoord2fARB_t orig_glMultiTexCoord2fARB;
extern func_glAccum_t orig_glAccum;
extern func_glAlphaFunc_t orig_glAlphaFunc;
extern func_glAreTexturesResident_t orig_glAreTexturesResident;
extern func_glArrayElement_t orig_glArrayElement;
extern func_glBegin_t orig_glBegin;
extern func_glBindTexture_t orig_glBindTexture;
extern func_glBitmap_t orig_glBitmap;
extern func_glBlendFunc_t orig_glBlendFunc;
extern func_glCallList_t orig_glCallList;
extern func_glCallLists_t orig_glCallLists;
extern func_glClear_t orig_glClear;
extern func_glClearAccum_t orig_glClearAccum;
extern func_glClearColor_t orig_glClearColor;
extern func_glClearDepth_t orig_glClearDepth;
extern func_glClearIndex_t orig_glClearIndex;
extern func_glClearStencil_t orig_glClearStencil;
extern func_glClipPlane_t orig_glClipPlane;
extern func_glColor3b_t orig_glColor3b;
extern func_glColor3bv_t orig_glColor3bv;
extern func_glColor3d_t orig_glColor3d;
extern func_glColor3dv_t orig_glColor3dv;
extern func_glColor3f_t orig_glColor3f;
extern func_glColor3fv_t orig_glColor3fv;
extern func_glColor3i_t orig_glColor3i;
extern func_glColor3iv_t orig_glColor3iv;
extern func_glColor3s_t orig_glColor3s;
extern func_glColor3sv_t orig_glColor3sv;
extern func_glColor3ub_t orig_glColor3ub;
extern func_glColor3ubv_t orig_glColor3ubv;
extern func_glColor3ui_t orig_glColor3ui;
extern func_glColor3uiv_t orig_glColor3uiv;
extern func_glColor3us_t orig_glColor3us;
extern func_glColor3usv_t orig_glColor3usv;
extern func_glColor4b_t orig_glColor4b;
extern func_glColor4bv_t orig_glColor4bv;
extern func_glColor4d_t orig_glColor4d;
extern func_glColor4dv_t orig_glColor4dv;
extern func_glColor4f_t orig_glColor4f;
extern func_glColor4fv_t orig_glColor4fv;
extern func_glColor4i_t orig_glColor4i;
extern func_glColor4iv_t orig_glColor4iv;
extern func_glColor4s_t orig_glColor4s;
extern func_glColor4sv_t orig_glColor4sv;
extern func_glColor4ub_t orig_glColor4ub;
extern func_glColor4ubv_t orig_glColor4ubv;
extern func_glColor4ui_t orig_glColor4ui;
extern func_glColor4uiv_t orig_glColor4uiv;
extern func_glColor4us_t orig_glColor4us;
extern func_glColor4usv_t orig_glColor4usv;
extern func_glColorMask_t orig_glColorMask;
extern func_glColorMaterial_t orig_glColorMaterial;
extern func_glColorPointer_t orig_glColorPointer;
extern func_glCopyPixels_t orig_glCopyPixels;
extern func_glCopyTexImage1D_t orig_glCopyTexImage1D;
extern func_glCopyTexImage2D_t orig_glCopyTexImage2D;
extern func_glCopyTexSubImage1D_t orig_glCopyTexSubImage1D;
extern func_glCopyTexSubImage2D_t orig_glCopyTexSubImage2D;
extern func_glCullFace_t orig_glCullFace;
extern func_glDebugEntry_t orig_glDebugEntry;
extern func_glDeleteLists_t orig_glDeleteLists;
extern func_glDeleteTextures_t orig_glDeleteTextures;
extern func_glDepthFunc_t orig_glDepthFunc;
extern func_glDepthMask_t orig_glDepthMask;
extern func_glDepthRange_t orig_glDepthRange;
extern func_glDisable_t orig_glDisable;
extern func_glDisableClientState_t orig_glDisableClientState;
extern func_glDrawArrays_t orig_glDrawArrays;
extern func_glDrawBuffer_t orig_glDrawBuffer;
extern func_glDrawElements_t orig_glDrawElements;
extern func_glDrawPixels_t orig_glDrawPixels;
extern func_glEdgeFlag_t orig_glEdgeFlag;
extern func_glEdgeFlagPointer_t orig_glEdgeFlagPointer;
extern func_glEdgeFlagv_t orig_glEdgeFlagv;
extern func_glEnable_t orig_glEnable;
extern func_glEnableClientState_t orig_glEnableClientState;
extern func_glEnd_t orig_glEnd;
extern func_glEndList_t orig_glEndList;
extern func_glEvalCoord1d_t orig_glEvalCoord1d;
extern func_glEvalCoord1dv_t orig_glEvalCoord1dv;
extern func_glEvalCoord1f_t orig_glEvalCoord1f;
extern func_glEvalCoord1fv_t orig_glEvalCoord1fv;
extern func_glEvalCoord2d_t orig_glEvalCoord2d;
extern func_glEvalCoord2dv_t orig_glEvalCoord2dv;
extern func_glEvalCoord2f_t orig_glEvalCoord2f;
extern func_glEvalCoord2fv_t orig_glEvalCoord2fv;
extern func_glEvalMesh1_t orig_glEvalMesh1;
extern func_glEvalMesh2_t orig_glEvalMesh2;
extern func_glEvalPoint1_t orig_glEvalPoint1;
extern func_glEvalPoint2_t orig_glEvalPoint2;
extern func_glFeedbackBuffer_t orig_glFeedbackBuffer;
extern func_glFinish_t orig_glFinish;
extern func_glFlush_t orig_glFlush;
extern func_glFogf_t orig_glFogf;
extern func_glFogfv_t orig_glFogfv;
extern func_glFogi_t orig_glFogi;
extern func_glFogiv_t orig_glFogiv;
extern func_glFrontFace_t orig_glFrontFace;
extern func_glFrustum_t orig_glFrustum;
extern func_glGenLists_t orig_glGenLists;
extern func_glGenTextures_t orig_glGenTextures;
extern func_glGetBooleanv_t orig_glGetBooleanv;
extern func_glGetClipPlane_t orig_glGetClipPlane;
extern func_glGetDoublev_t orig_glGetDoublev;
extern func_glGetError_t orig_glGetError;
extern func_glGetFloatv_t orig_glGetFloatv;
extern func_glGetIntegerv_t orig_glGetIntegerv;
extern func_glGetLightfv_t orig_glGetLightfv;
extern func_glGetLightiv_t orig_glGetLightiv;
extern func_glGetMapdv_t orig_glGetMapdv;
extern func_glGetMapfv_t orig_glGetMapfv;
extern func_glGetMapiv_t orig_glGetMapiv;
extern func_glGetMaterialfv_t orig_glGetMaterialfv;
extern func_glGetMaterialiv_t orig_glGetMaterialiv;
extern func_glGetPixelMapfv_t orig_glGetPixelMapfv;
extern func_glGetPixelMapuiv_t orig_glGetPixelMapuiv;
extern func_glGetPixelMapusv_t orig_glGetPixelMapusv;
extern func_glGetPointerv_t orig_glGetPointerv;
extern func_glGetPolygonStipple_t orig_glGetPolygonStipple;
extern func_glGetString_t orig_glGetString;
extern func_glGetTexEnvfv_t orig_glGetTexEnvfv;
extern func_glGetTexEnviv_t orig_glGetTexEnviv;
extern func_glGetTexGendv_t orig_glGetTexGendv;
extern func_glGetTexGenfv_t orig_glGetTexGenfv;
extern func_glGetTexGeniv_t orig_glGetTexGeniv;
extern func_glGetTexImage_t orig_glGetTexImage;
extern func_glGetTexLevelParameterfv_t orig_glGetTexLevelParameterfv;
extern func_glGetTexLevelParameteriv_t orig_glGetTexLevelParameteriv;
extern func_glGetTexParameterfv_t orig_glGetTexParameterfv;
extern func_glGetTexParameteriv_t orig_glGetTexParameteriv;
extern func_glHint_t orig_glHint;
extern func_glIndexMask_t orig_glIndexMask;
extern func_glIndexPointer_t orig_glIndexPointer;
extern func_glIndexd_t orig_glIndexd;
extern func_glIndexdv_t orig_glIndexdv;
extern func_glIndexf_t orig_glIndexf;
extern func_glIndexfv_t orig_glIndexfv;
extern func_glIndexi_t orig_glIndexi;
extern func_glIndexiv_t orig_glIndexiv;
extern func_glIndexs_t orig_glIndexs;
extern func_glIndexsv_t orig_glIndexsv;
extern func_glIndexub_t orig_glIndexub;
extern func_glIndexubv_t orig_glIndexubv;
extern func_glInitNames_t orig_glInitNames;
extern func_glInterleavedArrays_t orig_glInterleavedArrays;
extern func_glIsEnabled_t orig_glIsEnabled;
extern func_glIsList_t orig_glIsList;
extern func_glIsTexture_t orig_glIsTexture;
extern func_glLightModelf_t orig_glLightModelf;
extern func_glLightModelfv_t orig_glLightModelfv;
extern func_glLightModeli_t orig_glLightModeli;
extern func_glLightModeliv_t orig_glLightModeliv;
extern func_glLightf_t orig_glLightf;
extern func_glLightfv_t orig_glLightfv;
extern func_glLighti_t orig_glLighti;
extern func_glLightiv_t orig_glLightiv;
extern func_glLineStipple_t orig_glLineStipple;
extern func_glLineWidth_t orig_glLineWidth;
extern func_glListBase_t orig_glListBase;
extern func_glLoadIdentity_t orig_glLoadIdentity;
extern func_glLoadMatrixd_t orig_glLoadMatrixd;
extern func_glLoadMatrixf_t orig_glLoadMatrixf;
extern func_glLoadName_t orig_glLoadName;
extern func_glLogicOp_t orig_glLogicOp;
extern func_glMap1d_t orig_glMap1d;
extern func_glMap1f_t orig_glMap1f;
extern func_glMap2d_t orig_glMap2d;
extern func_glMap2f_t orig_glMap2f;
extern func_glMapGrid1d_t orig_glMapGrid1d;
extern func_glMapGrid1f_t orig_glMapGrid1f;
extern func_glMapGrid2d_t orig_glMapGrid2d;
extern func_glMapGrid2f_t orig_glMapGrid2f;
extern func_glMaterialf_t orig_glMaterialf;
extern func_glMaterialfv_t orig_glMaterialfv;
extern func_glMateriali_t orig_glMateriali;
extern func_glMaterialiv_t orig_glMaterialiv;
extern func_glMatrixMode_t orig_glMatrixMode;
extern func_glMultMatrixd_t orig_glMultMatrixd;
extern func_glMultMatrixf_t orig_glMultMatrixf;
extern func_glNewList_t orig_glNewList;
extern func_glNormal3b_t orig_glNormal3b;
extern func_glNormal3bv_t orig_glNormal3bv;
extern func_glNormal3d_t orig_glNormal3d;
extern func_glNormal3dv_t orig_glNormal3dv;
extern func_glNormal3f_t orig_glNormal3f;
extern func_glNormal3fv_t orig_glNormal3fv;
extern func_glNormal3i_t orig_glNormal3i;
extern func_glNormal3iv_t orig_glNormal3iv;
extern func_glNormal3s_t orig_glNormal3s;
extern func_glNormal3sv_t orig_glNormal3sv;
extern func_glNormalPointer_t orig_glNormalPointer;
extern func_glOrtho_t orig_glOrtho;
extern func_glPassThrough_t orig_glPassThrough;
extern func_glPixelMapfv_t orig_glPixelMapfv;
extern func_glPixelMapuiv_t orig_glPixelMapuiv;
extern func_glPixelMapusv_t orig_glPixelMapusv;
extern func_glPixelStoref_t orig_glPixelStoref;
extern func_glPixelStorei_t orig_glPixelStorei;
extern func_glPixelTransferf_t orig_glPixelTransferf;
extern func_glPixelTransferi_t orig_glPixelTransferi;
extern func_glPixelZoom_t orig_glPixelZoom;
extern func_glPointSize_t orig_glPointSize;
extern func_glPolygonMode_t orig_glPolygonMode;
extern func_glPolygonOffset_t orig_glPolygonOffset;
extern func_glPolygonStipple_t orig_glPolygonStipple;
extern func_glPopAttrib_t orig_glPopAttrib;
extern func_glPopClientAttrib_t orig_glPopClientAttrib;
extern func_glPopMatrix_t orig_glPopMatrix;
extern func_glPopName_t orig_glPopName;
extern func_glPrioritizeTextures_t orig_glPrioritizeTextures;
extern func_glPushAttrib_t orig_glPushAttrib;
extern func_glPushClientAttrib_t orig_glPushClientAttrib;
extern func_glPushMatrix_t orig_glPushMatrix;
extern func_glPushName_t orig_glPushName;
extern func_glRasterPos2d_t orig_glRasterPos2d;
extern func_glRasterPos2dv_t orig_glRasterPos2dv;
extern func_glRasterPos2f_t orig_glRasterPos2f;
extern func_glRasterPos2fv_t orig_glRasterPos2fv;
extern func_glRasterPos2i_t orig_glRasterPos2i;
extern func_glRasterPos2iv_t orig_glRasterPos2iv;
extern func_glRasterPos2s_t orig_glRasterPos2s;
extern func_glRasterPos2sv_t orig_glRasterPos2sv;
extern func_glRasterPos3d_t orig_glRasterPos3d;
extern func_glRasterPos3dv_t orig_glRasterPos3dv;
extern func_glRasterPos3f_t orig_glRasterPos3f;
extern func_glRasterPos3fv_t orig_glRasterPos3fv;
extern func_glRasterPos3i_t orig_glRasterPos3i;
extern func_glRasterPos3iv_t orig_glRasterPos3iv;
extern func_glRasterPos3s_t orig_glRasterPos3s;
extern func_glRasterPos3sv_t orig_glRasterPos3sv;
extern func_glRasterPos4d_t orig_glRasterPos4d;
extern func_glRasterPos4dv_t orig_glRasterPos4dv;
extern func_glRasterPos4f_t orig_glRasterPos4f;
extern func_glRasterPos4fv_t orig_glRasterPos4fv;
extern func_glRasterPos4i_t orig_glRasterPos4i;
extern func_glRasterPos4iv_t orig_glRasterPos4iv;
extern func_glRasterPos4s_t orig_glRasterPos4s;
extern func_glRasterPos4sv_t orig_glRasterPos4sv;
extern func_glReadBuffer_t orig_glReadBuffer;
extern func_glReadPixels_t orig_glReadPixels;
extern func_glRectd_t orig_glRectd;
extern func_glRectdv_t orig_glRectdv;
extern func_glRectf_t orig_glRectf;
extern func_glRectfv_t orig_glRectfv;
extern func_glRecti_t orig_glRecti;
extern func_glRectiv_t orig_glRectiv;
extern func_glRects_t orig_glRects;
extern func_glRectsv_t orig_glRectsv;
extern func_glRenderMode_t orig_glRenderMode;
extern func_glRotated_t orig_glRotated;
extern func_glRotatef_t orig_glRotatef;
extern func_glScaled_t orig_glScaled;
extern func_glScalef_t orig_glScalef;
extern func_glScissor_t orig_glScissor;
extern func_glSelectBuffer_t orig_glSelectBuffer;
extern func_glShadeModel_t orig_glShadeModel;
extern func_glStencilFunc_t orig_glStencilFunc;
extern func_glStencilMask_t orig_glStencilMask;
extern func_glStencilOp_t orig_glStencilOp;
extern func_glSwapBuffers_t orig_glSwapBuffers;
extern func_glTexCoord1d_t orig_glTexCoord1d;
extern func_glTexCoord1dv_t orig_glTexCoord1dv;
extern func_glTexCoord1f_t orig_glTexCoord1f;
extern func_glTexCoord1fv_t orig_glTexCoord1fv;
extern func_glTexCoord1i_t orig_glTexCoord1i;
extern func_glTexCoord1iv_t orig_glTexCoord1iv;
extern func_glTexCoord1s_t orig_glTexCoord1s;
extern func_glTexCoord1sv_t orig_glTexCoord1sv;
extern func_glTexCoord2d_t orig_glTexCoord2d;
extern func_glTexCoord2dv_t orig_glTexCoord2dv;
extern func_glTexCoord2f_t orig_glTexCoord2f;
extern func_glTexCoord2fv_t orig_glTexCoord2fv;
extern func_glTexCoord2i_t orig_glTexCoord2i;
extern func_glTexCoord2iv_t orig_glTexCoord2iv;
extern func_glTexCoord2s_t orig_glTexCoord2s;
extern func_glTexCoord2sv_t orig_glTexCoord2sv;
extern func_glTexCoord3d_t orig_glTexCoord3d;
extern func_glTexCoord3dv_t orig_glTexCoord3dv;
extern func_glTexCoord3f_t orig_glTexCoord3f;
extern func_glTexCoord3fv_t orig_glTexCoord3fv;
extern func_glTexCoord3i_t orig_glTexCoord3i;
extern func_glTexCoord3iv_t orig_glTexCoord3iv;
extern func_glTexCoord3s_t orig_glTexCoord3s;
extern func_glTexCoord3sv_t orig_glTexCoord3sv;
extern func_glTexCoord4d_t orig_glTexCoord4d;
extern func_glTexCoord4dv_t orig_glTexCoord4dv;
extern func_glTexCoord4f_t orig_glTexCoord4f;
extern func_glTexCoord4fv_t orig_glTexCoord4fv;
extern func_glTexCoord4i_t orig_glTexCoord4i;
extern func_glTexCoord4iv_t orig_glTexCoord4iv;
extern func_glTexCoord4s_t orig_glTexCoord4s;
extern func_glTexCoord4sv_t orig_glTexCoord4sv;
extern func_glTexCoordPointer_t orig_glTexCoordPointer;
extern func_glTexEnvf_t orig_glTexEnvf;
extern func_glTexEnvfv_t orig_glTexEnvfv;
extern func_glTexEnvi_t orig_glTexEnvi;
extern func_glTexEnviv_t orig_glTexEnviv;
extern func_glTexGend_t orig_glTexGend;
extern func_glTexGendv_t orig_glTexGendv;
extern func_glTexGenf_t orig_glTexGenf;
extern func_glTexGenfv_t orig_glTexGenfv;
extern func_glTexGeni_t orig_glTexGeni;
extern func_glTexGeniv_t orig_glTexGeniv;
extern func_glTexImage1D_t orig_glTexImage1D;
extern func_glTexImage2D_t orig_glTexImage2D;
extern func_glTexParameterf_t orig_glTexParameterf;
extern func_glTexParameterfv_t orig_glTexParameterfv;
extern func_glTexParameteri_t orig_glTexParameteri;
extern func_glTexParameteriv_t orig_glTexParameteriv;
extern func_glTexSubImage1D_t orig_glTexSubImage1D;
extern func_glTexSubImage2D_t orig_glTexSubImage2D;
extern func_glTranslated_t orig_glTranslated;
extern func_glTranslatef_t orig_glTranslatef;
extern func_glVertex2d_t orig_glVertex2d;
extern func_glVertex2dv_t orig_glVertex2dv;
extern func_glVertex2f_t orig_glVertex2f;
extern func_glVertex2fv_t orig_glVertex2fv;
extern func_glVertex2i_t orig_glVertex2i;
extern func_glVertex2iv_t orig_glVertex2iv;
extern func_glVertex2s_t orig_glVertex2s;
extern func_glVertex2sv_t orig_glVertex2sv;
extern func_glVertex3d_t orig_glVertex3d;
extern func_glVertex3dv_t orig_glVertex3dv;
extern func_glVertex3f_t orig_glVertex3f;
extern func_glVertex3fv_t orig_glVertex3fv;
extern func_glVertex3i_t orig_glVertex3i;
extern func_glVertex3iv_t orig_glVertex3iv;
extern func_glVertex3s_t orig_glVertex3s;
extern func_glVertex3sv_t orig_glVertex3sv;
extern func_glVertex4d_t orig_glVertex4d;
extern func_glVertex4dv_t orig_glVertex4dv;
extern func_glVertex4f_t orig_glVertex4f;
extern func_glVertex4fv_t orig_glVertex4fv;
extern func_glVertex4i_t orig_glVertex4i;
extern func_glVertex4iv_t orig_glVertex4iv;
extern func_glVertex4s_t orig_glVertex4s;
extern func_glVertex4sv_t orig_glVertex4sv;
extern func_glVertexPointer_t orig_glVertexPointer;
extern func_glViewport_t orig_glViewport;
extern func_wglChoosePixelFormat_t orig_wglChoosePixelFormat;
extern func_wglCopyContext_t orig_wglCopyContext;
extern func_wglCreateContext_t orig_wglCreateContext;
extern func_wglCreateLayerContext_t orig_wglCreateLayerContext;
extern func_wglDeleteContext_t orig_wglDeleteContext;
extern func_wglDescribeLayerPlane_t orig_wglDescribeLayerPlane;
extern func_wglDescribePixelFormat_t orig_wglDescribePixelFormat;
extern func_wglGetCurrentContext_t orig_wglGetCurrentContext;
extern func_wglGetCurrentDC_t orig_wglGetCurrentDC;
extern func_wglGetDefaultProcAddress_t orig_wglGetDefaultProcAddress;
extern func_wglGetLayerPaletteEntries_t orig_wglGetLayerPaletteEntries;
extern func_wglGetPixelFormat_t orig_wglGetPixelFormat;
extern func_wglGetProcAddress_t orig_wglGetProcAddress;
extern func_wglMakeCurrent_t orig_wglMakeCurrent;
extern func_wglRealizeLayerPalette_t orig_wglRealizeLayerPalette;
extern func_wglSetLayerPaletteEntries_t orig_wglSetLayerPaletteEntries;
extern func_wglSetPixelFormat_t orig_wglSetPixelFormat;
extern func_wglShareLists_t orig_wglShareLists;
extern func_wglSwapBuffers_t orig_wglSwapBuffers;
extern func_wglSwapLayerBuffers_t orig_wglSwapLayerBuffers;
extern func_wglUseFontBitmapsA_t orig_wglUseFontBitmapsA;
extern func_wglUseFontBitmapsW_t orig_wglUseFontBitmapsW;
extern func_wglUseFontOutlinesA_t orig_wglUseFontOutlinesA;
extern func_wglUseFontOutlinesW_t orig_wglUseFontOutlinesW;
extern func_glBegin_t orig_exp_glBegin;
extern DWORD *exp_glBegin;
extern func_glDrawElements_t orig_exp_glDrawElements;
extern DWORD *exp_glDrawElements;
extern func_glViewport_t orig_exp_glViewport;
extern DWORD *exp_glViewport;
#ifdef __cplusplus
}
#endif
#endif
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
-191
View File
@@ -1,191 +0,0 @@
/***************************************************************************
* Copyright (C) 2012, Chain Studios.
*
* This file is part of QeffectsGL source code.
*
* QeffectsGL source code 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.
*
* QeffectsGL source code 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 St, Fifth Floor, Boston, MA 02110-1301 USA
***************************************************************************/
#include "qfx_library.h"
#include "qfx_log.h"
#include "qfx_opengl.h"
#include "qfx_renderer.h"
//=========================================
// QFX Library Hooks
//-----------------------------------------
// Call our renderer in proper places
//=========================================
static const char s_szCustomVendorName[] = QFX_LIBRARY_VENDOR;
static GLenum s_glMatrixMode = GL_MODELVIEW;
#define IS_3D_PROJECTION_MATRIX(x) ( x[2*4+3] < 0 )
const GLubyte * WINAPI glGetString( GLenum name )
{
if ( name == GL_VENDOR )
return reinterpret_cast<const GLubyte*>(s_szCustomVendorName);
else
return gl::qglGetString( name );
}
void WINAPI glMatrixMode( GLenum mode )
{
s_glMatrixMode = mode;
gl::qglMatrixMode( mode );
}
void WINAPI glLoadMatrixd( const GLdouble *m )
{
gl::qglLoadMatrixd( m );
if ( s_glMatrixMode == GL_PROJECTION ) {
if ( gl::ext.FBO ) {
GLuint fboBinding = 0;
gl::qglGetIntegerv( GL_FRAMEBUFFER_BINDING_EXT, (GLint*)&fboBinding );
if ( fboBinding ) return;
}
if ( IS_3D_PROJECTION_MATRIX(m) ) {
QFXRenderer::Instance().SetupZDimensions( m );
QFXRenderer::Instance().SetOrtho( GL_FALSE );
} else {
QFXRenderer::Instance().SetOrtho( GL_TRUE );
}
}
}
void WINAPI glLoadMatrixf( const GLfloat *m )
{
gl::qglLoadMatrixf( m );
if ( s_glMatrixMode == GL_PROJECTION ) {
if ( gl::ext.FBO ) {
GLuint fboBinding = 0;
gl::qglGetIntegerv( GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&fboBinding );
if ( fboBinding ) return;
}
if ( IS_3D_PROJECTION_MATRIX(m) ) {
QFXRenderer::Instance().SetupZDimensions( m );
QFXRenderer::Instance().SetOrtho( GL_FALSE );
} else {
QFXRenderer::Instance().SetOrtho( GL_TRUE );
}
}
}
void WINAPI glFrustum( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar )
{
gl::qglFrustum( left, right, bottom, top, zNear, zFar );
if ( s_glMatrixMode == GL_PROJECTION ) {
if ( gl::ext.FBO ) {
GLuint fboBinding = 0;
gl::qglGetIntegerv( GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&fboBinding );
if ( fboBinding ) return;
}
QFXRenderer::Instance().SetupZDimensions( (GLfloat)zNear, (GLfloat)zFar );
QFXRenderer::Instance().SetOrtho( GL_FALSE );
}
}
void WINAPI glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar )
{
gl::qglOrtho( left, right, bottom, top, zNear, zFar );
if ( s_glMatrixMode == GL_PROJECTION ) {
if ( gl::ext.FBO ) {
GLuint fboBinding = 0;
gl::qglGetIntegerv( GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&fboBinding );
if ( fboBinding ) return;
}
QFXRenderer::Instance().SetOrtho( GL_TRUE );
}
}
void WINAPI glDepthFunc( GLenum func )
{
QFXRenderer::Instance().SetupDepthFunc( func );
}
void WINAPI glDepthRange( GLclampd zNear, GLclampd zFar )
{
QFXRenderer::Instance().SetupDepthRange( zNear, zFar );
}
void WINAPI glTexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
{
gl::qglTexImage2D( target, level, internalformat, width, height, border, format, type, pixels );
if ( (target == GL_TEXTURE_2D) && !level && pixels )
QFXRenderer::Instance().OnTexImage2D();
}
void WINAPI glTexParameterf( GLenum target, GLenum pname, GLfloat param )
{
if ( ( pname == GL_TEXTURE_MAX_ANISOTROPY_EXT ) && ( param > 1 ) )
QFXRenderer::Instance().SetupAnisotropy();
gl::qglTexParameterf( target, pname, param );
}
void WINAPI glTexParameteri( GLenum target, GLenum pname, GLint param )
{
if ( ( pname == GL_TEXTURE_MAX_ANISOTROPY_EXT ) && ( param > 1 ) )
QFXRenderer::Instance().SetupAnisotropy();
gl::qglTexParameteri( target, pname, param );
}
void WINAPI glEnable( GLenum cap )
{
if ( cap == GL_MULTISAMPLE_ARB )
QFXRenderer::Instance().SetupMultisample();
gl::qglEnable( cap );
}
int WINAPI wrap_wglChoosePixelFormat( HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd )
{
PIXELFORMATDESCRIPTOR newPfd;
memcpy( &newPfd, ppfd, sizeof( PIXELFORMATDESCRIPTOR ) );
newPfd.cColorBits = 32;
gl::CheckInit();
return gl::wglChoosePixelFormat( hdc, &newPfd );
}
BOOL WINAPI wrap_wglSetPixelFormat( HDC hdc, int i, CONST PIXELFORMATDESCRIPTOR *pfd )
{
gl::CheckInit();
return QFXRenderer::Instance().OnSetPixelFormat( hdc, i, pfd );
}
BOOL WINAPI wrap_wglMakeCurrent( HDC hdc, HGLRC hglrc )
{
gl::CheckInit();
if (!gl::wglMakeCurrent(hdc, hglrc))
return FALSE;
QFXRenderer::Instance().OnMakeCurrent( hdc, hglrc );
return TRUE;
}
BOOL WINAPI wrap_wglDeleteContext( HGLRC hglrc )
{
gl::CheckInit();
QFXRenderer::Instance().OnDeleteContext( hglrc );
return gl::wglDeleteContext( hglrc );
}
BOOL WINAPI wrap_wglSwapBuffers( HDC hdc )
{
gl::CheckInit();
QFXRenderer::Instance().OnSwapBuffers();
return gl::wglSwapBuffers( hdc );
}
-42
View File
@@ -1,42 +0,0 @@
/***************************************************************************
* Copyright (C) 2012, Chain Studios.
*
* This file is part of QeffectsGL source code.
*
* QeffectsGL source code 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.
*
* QeffectsGL source code 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 St, Fifth Floor, Boston, MA 02110-1301 USA
***************************************************************************/
#ifndef QFX_LIBRARY_H
#define QFX_LIBRARY_H
#include <cassert>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <cmath>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mmsystem.h>
#define QFX_LIBRARY_TITLE "QeffectsGL"
#define QFX_LIBRARY_VERSION "1.2"
#define QFX_LIBRARY_VENDOR "Chain Studios (" QFX_LIBRARY_TITLE " " QFX_LIBRARY_VERSION ")"
#define QFX_SINGLETON
// make sure these identifiers do not conflict with anything
#define QFX_TEXTURE_IDENTIFIER_BASE 0xFFAA
#endif //QFX_LIBRARY_H
-138
View File
@@ -1,138 +0,0 @@
/***************************************************************************
* Copyright (C) 2012, Chain Studios.
*
* This file is part of QeffectsGL source code.
*
* QeffectsGL source code 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.
*
* QeffectsGL source code 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 St, Fifth Floor, Boston, MA 02110-1301 USA
***************************************************************************/
#include "qfx_library.h"
#include "qfx_log.h"
#include "glb_local.h"
//=========================================
// QFXLog class implementation
//-----------------------------------------
// Print messages to log file
//=========================================
#define QFX_LOG_FILENAME QFX_LIBRARY_TITLE ".log"
#define QFX_LOG_MAXSTRING 8192
QFXLog :: QFXLog() : m_pszLogString( NULL ), m_pFile( NULL )
{
m_pszLogString = new char[ QFX_LOG_MAXSTRING ];
assert( m_pszLogString != NULL );
/*char timeBuf[64];
time_t t;
if ( fopen_s( &m_pFile, QFX_LOG_FILENAME, "w" ) )
return;
m_pszLogString = new char[QFX_LOG_MAXSTRING];
assert( m_pszLogString != NULL );
memset( &t, 0, sizeof(t) );
time( &t );
memset( timeBuf, 0, sizeof(timeBuf) );
ctime_s( timeBuf, sizeof(timeBuf), &t );
fprintf( m_pFile, "==================================================================\n" );
fprintf( m_pFile, " " QFX_LIBRARY_TITLE " initialized at %s", timeBuf );
fprintf( m_pFile, "==================================================================\n" );
fprintf( m_pFile, "\n" );
fflush( m_pFile );*/
}
QFXLog :: ~QFXLog()
{
/*if ( m_pszLogString ) {
delete [] m_pszLogString;
m_pszLogString = NULL;
}
if ( m_pFile ) {
char timeBuf[64];
time_t t;
memset( &t, 0, sizeof(t) );
time( &t );
memset( timeBuf, 0, sizeof(timeBuf) );
ctime_s( timeBuf, sizeof(timeBuf), &t );
fprintf( m_pFile, "\n==================================================================\n" );
fprintf( m_pFile, " " QFX_LIBRARY_TITLE " shutdown at %s", timeBuf );
fprintf( m_pFile, "==================================================================\n" );
fclose( m_pFile );
m_pFile = NULL;
}*/
}
void QFXLog :: Printf( const char *fmt, ... )
{
va_list argptr;
//if ( !m_pFile || !m_pszLogString )
// return;
if( !m_pszLogString )
return;
va_start( argptr, fmt );
_vsnprintf_s( m_pszLogString, QFX_LOG_MAXSTRING, QFX_LOG_MAXSTRING-1, fmt, argptr );
va_end( argptr );
cgi.Printf( m_pszLogString );
//fputs( m_pszLogString, m_pFile );
//fflush( m_pFile );
}
void QFXLog :: Error( const char *fmt, ... )
{
va_list argptr;
if ( !m_pFile || !m_pszLogString )
return;
va_start( argptr, fmt );
_vsnprintf_s( m_pszLogString, QFX_LOG_MAXSTRING, QFX_LOG_MAXSTRING-1, fmt, argptr );
va_end( argptr );
cgi.Printf( m_pszLogString );
//fprintf( m_pFile, "ERROR: %s", m_pszLogString );
//fflush( m_pFile );
}
void QFXLog :: Warning( const char *fmt, ... )
{
va_list argptr;
if ( !m_pFile || !m_pszLogString )
return;
va_start( argptr, fmt );
_vsnprintf_s( m_pszLogString, QFX_LOG_MAXSTRING, QFX_LOG_MAXSTRING-1, fmt, argptr );
va_end( argptr );
cgi.Printf( m_pszLogString );
//fprintf( m_pFile, "WARNING: %s", m_pszLogString );
//fflush( m_pFile );
}
-42
View File
@@ -1,42 +0,0 @@
/***************************************************************************
* Copyright (C) 2012, Chain Studios.
*
* This file is part of QeffectsGL source code.
*
* QeffectsGL source code 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.
*
* QeffectsGL source code 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 St, Fifth Floor, Boston, MA 02110-1301 USA
***************************************************************************/
#ifndef QFX_LOG_H
#define QFX_LOG_H
QFX_SINGLETON class QFXLog
{
private:
QFXLog();
static QFXLog& GetInstance() { static QFXLog logObject; return logObject; }
public:
~QFXLog();
static QFXLog& Instance() { typedef QFXLog& (*pfnGetInstance)(); static pfnGetInstance pf = &GetInstance; return pf(); }
void Printf( const char *fmt, ... );
void Error( const char *fmt, ... );
void Warning( const char *fmt, ... );
private:
FILE* m_pFile;
char* m_pszLogString;
};
#endif //QFX_LOG_H
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
-179
View File
@@ -1,179 +0,0 @@
/***************************************************************************
* Copyright (C) 2012, Chain Studios.
*
* This file is part of QeffectsGL source code.
*
* QeffectsGL source code 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.
*
* QeffectsGL source code 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 St, Fifth Floor, Boston, MA 02110-1301 USA
***************************************************************************/
#ifndef QFX_RENDERER_H
#define QFX_RENDERER_H
class QFXShader;
QFX_SINGLETON class QFXRenderer
{
private:
QFXRenderer();
static QFXRenderer& GetInstance() { static QFXRenderer rObject; return rObject; }
public:
static QFXRenderer& Instance() { typedef QFXRenderer& (*pfnGetInstance)(); static pfnGetInstance pf = &GetInstance; return pf(); }
void GetVariables( void );
void InitializeGL( void );
BOOL OnSetPixelFormat( HDC hdc, int pixelformat, CONST PIXELFORMATDESCRIPTOR *ppfd );
void OnMakeCurrent( HDC hdc, HGLRC hglrc );
void OnDeleteContext( HGLRC hglrc );
void OnSwapBuffers( void );
void OnTexImage2D( void );
void PostProcess( void );
void RenderGL( void );
void SetOrtho( GLboolean enable );
void SetupZDimensions( GLfloat znear, GLfloat zfar );
void SetupZDimensions( const GLfloat* matrix );
void SetupZDimensions( const GLdouble* matrix );
void SetupDepthFunc( GLenum func );
void SetupDepthRange( GLclampd zNear, GLclampd zFar );
void SetupMultisample( void );
void SetupAnisotropy( void );
void ProcessShadow1( void );
void ProcessShadow2( void );
void PreRenderScene( struct refDef_s *fd );
void PostRenderScene( void );
private:
GLuint AllocTextureId( void ) { return m_uiTextureIndex++; }
int ChooseMultisamplePixelFormat( int fmt, HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd );
void CheckHardware( void );
void ShutdownGL( void );
void CaptureRGB( void );
void CaptureDepth( void );
void RenderFSQ( int wide, int tall );
void RenderScaledFSQ( int wide, int tall, int wide2, int tall2 );
//void PostProcess( void );
void PostProcess_SSAO( void );
void PostProcess_Bloom( void );
void PostProcess_ColorCorrection( void );
void PostProcess_Emboss( void );
void PostProcess_DOF( void );
void PostProcess_BrightnessContrast( void );
void PostProcess_Tint( void );
void PostProcess_Bleach( void );
void PostProcess_MotionBlur( void );
void PostProcess_Reflections( void );
void PostProcess_Shadows( void );
void PostProcess_FXAA( void );
void PostProcess_Distortion( void );
void PostProcess_Blur( void );
private:
// contexts, internal state
HDC m_hDC;
HGLRC m_hGLRC;
GLboolean m_bOrtho;
GLboolean m_bZTrick;
GLboolean m_bInternalAnisotropy;
GLboolean m_bInternalMultisample;
GLboolean m_bMultisample;
GLuint m_uiRenderFrame;
GLuint m_uiRenderFrameCounter;
GLuint m_uiFrameCounter;
GLuint m_uiTextureIndex;
GLint m_WindowSize[2];
GLfloat m_zNear;
GLfloat m_zFar;
DWORD m_iEnableRender;
GLfloat m_flFrameTime;
DWORD m_flOldTime;
DWORD m_flLastTime;
GLfloat m_flLastDepth;
GLuint m_uiFrameBuffer;
// tracked GL state
GLuint m_uiViewportFrame;
GLint m_3DViewport[4];
GLint m_3DScissor[4];
// hardware caps
GLboolean m_bSupportsBloom;
GLboolean m_bSupportsSSAO;
GLboolean m_bSupportsColorCorrection;
GLboolean m_bSupportsEmboss;
GLboolean m_bSupportsDOF;
// renderer settings
int m_varDebug;
int m_varCompareMode;
int m_varZTrickFix;
int m_varViewportFix;
int m_varRenderFrame;
int m_varAnisotropy;
int m_varMultisample;
int m_varMultisampleHint;
int m_varBloomEnable;
int m_varBloomNumSteps;
float m_varBloomDarkenPower;
float m_varBloomRadius0;
float m_varBloomRadius1;
float m_varBloomCombineScale0;
float m_varBloomCombineScale1;
int m_varSSAOEnable;
float m_varSSAOScale;
float m_varSSAOMinZ;
float m_varSSAOMaxZ;
int m_varHue;
int m_varSaturation;
int m_varLightness;
int m_varEmboss;
float m_varEmbossScale;
int m_varDOF;
float m_varDOFSpeed;
float m_varDOFScale;
float m_varDOFMinZ;
public:
// renderer data
GLuint m_uiScreenRGB;
GLuint m_uiScreenDepth;
GLuint m_uiBlurTexture;
GLuint m_uiBlurDepth;
GLuint m_uiShadowDepth;
QFXShader* m_pBloomDarkenShader;
QFXShader* m_pBloomBlurShader;
QFXShader* m_pBloomBlurVertShader;
QFXShader* m_pBloomCombineShader;
QFXShader* m_pSSAORenderShader;
QFXShader* m_pSSAOBlurShader;
QFXShader* m_pSSAOCombineShader;
QFXShader* m_pHSLShader;
QFXShader* m_pEmbossShader;
QFXShader* m_pDOFBlurShader;
QFXShader* m_pDOFDepthShader;
QFXShader* m_pDOFRenderShader;
QFXShader* m_pBrightnessContrastShader;
QFXShader* m_pTintShader;
QFXShader* m_pLightTintShader;
QFXShader* m_pMidTintShader;
QFXShader* m_pDarkTintShader;
QFXShader* m_pBleachShader;
QFXShader* m_pDistortionShader;
QFXShader* m_pBlurShader;
QFXShader* m_pFXAAShader;
QFXShader* m_pDisplacement;
QFXShader* m_pShadowMapping;
};
#endif //QFX_RENDERER_H
-94
View File
@@ -1,94 +0,0 @@
/***************************************************************************
* Copyright (C) 2012, Chain Studios.
*
* This file is part of QeffectsGL source code.
*
* QeffectsGL source code 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.
*
* QeffectsGL source code 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 St, Fifth Floor, Boston, MA 02110-1301 USA
***************************************************************************/
#include "qfx_library.h"
#include "qfx_log.h"
#include "qfx_settings.h"
//=========================================
// QFXSettings class implementation
//-----------------------------------------
// Load settings from INI file
//=========================================
QFXSettings :: QFXSettings()
{
// get current executable name
/*if (!GetModuleFileName( NULL, m_szExeName, sizeof(m_szExeName)-1 )) {
m_szExeName[0] = 0;
}
if ( m_szExeName[1] != ':' ) {
// not a full path, assume current directory for INI
GetCurrentDirectory( sizeof(m_szIniFile)-1, m_szIniFile );
strcat_s( m_szIniFile, "\\" QFX_LIBRARY_TITLE ".ini" );
} else {
// full path, assume its directory for INI
strcpy_s( m_szIniFile, m_szExeName );
size_t l = strlen( m_szIniFile );
for ( size_t i = l - 1; i > 0; i-- ) {
if ( m_szIniFile[i] == '\\' || m_szIniFile[i] == '/' ) {
m_szIniFile[i] = 0;
break;
}
}
strcat_s( m_szIniFile, "\\" QFX_LIBRARY_TITLE ".ini" );
}
char *p1 = strrchr( m_szExeName, '\\' );
char *p2 = strrchr( m_szExeName, '/' );
char *p = p1 > p2 ? p1 : p2;
if ( p )
strncpy_s( m_szExeName, p + 1, strlen( p + 1 ) );
QFXLog::Instance().Printf("Settings: %s\n", m_szIniFile);
QFXLog::Instance().Printf("Module: %s\n", m_szExeName);*/
}
QFXSettings :: ~QFXSettings()
{
}
int QFXSettings :: GetInteger( const char *setting, int defaultValue )
{
int value = GetPrivateProfileInt( m_szExeName, setting, -99999, m_szIniFile );
if ( value == -99999 )
return GetPrivateProfileInt( "Generic", setting, defaultValue, m_szIniFile );
else
return value;
}
float QFXSettings :: GetFloat( const char *setting, float defaultValue )
{
char buffer[32];
GetPrivateProfileString( m_szExeName, setting, NULL, buffer, sizeof(buffer)-1, m_szIniFile );
if ( !strlen( buffer ) ) {
GetPrivateProfileString( "Generic", setting, NULL, buffer, sizeof(buffer)-1, m_szIniFile );
if ( !strlen( buffer ) )
return defaultValue;
}
return (float)atof( buffer );
}
bool QFXSettings :: CheckEXE( const char *s )
{
if ( !_stricmp( m_szExeName, s ) )
return true;
return false;
}
-42
View File
@@ -1,42 +0,0 @@
/***************************************************************************
* Copyright (C) 2012, Chain Studios.
*
* This file is part of QeffectsGL source code.
*
* QeffectsGL source code 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.
*
* QeffectsGL source code 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 St, Fifth Floor, Boston, MA 02110-1301 USA
***************************************************************************/
#ifndef QFX_SETTINGS_H
#define QFX_SETTINGS_H
QFX_SINGLETON class QFXSettings
{
private:
QFXSettings();
static QFXSettings& GetInstance() { static QFXSettings sObject; return sObject; }
public:
~QFXSettings();
static QFXSettings& Instance() { typedef QFXSettings& (*pfnGetInstance)(); static pfnGetInstance pf = &GetInstance; return pf(); }
bool CheckEXE( const char *s );
int GetInteger( const char *setting, int defaultValue );
float GetFloat( const char *setting, float defaultValue );
private:
char m_szIniFile[MAX_PATH];
char m_szExeName[MAX_PATH];
};
#endif //QFX_SETTINGS_H
-200
View File
@@ -1,200 +0,0 @@
/***************************************************************************
* Copyright (C) 2012, Chain Studios.
*
* This file is part of QeffectsGL source code.
*
* QeffectsGL source code 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.
*
* QeffectsGL source code 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 St, Fifth Floor, Boston, MA 02110-1301 USA
***************************************************************************/
#include "qfx_library.h"
#include "qfx_log.h"
#include "qfx_opengl.h"
#include "qfx_shader.h"
#include "glb_local.h"
//=========================================
// QFXShader class implementation
//-----------------------------------------
// Class for GLSL shader objects
//=========================================
using namespace gl;
QFXShader :: QFXShader( const char *szvp, const char *szfp, const char *program_name )
{
GLint objectStatus;
char nameBuffer[16];
m_bValid = false;
m_hVShader = 0;
m_hFShader = 0;
m_hProgram = 0;
if ( !szvp && !szfp )
return;
if ( szvp ) {
qglGetError();
m_hVShader = qglCreateShaderObjectARB( GL_VERTEX_SHADER_ARB );
GLint srcLen = strlen( szvp );
qglShaderSourceARB( m_hVShader, 1, (const char**)&szvp, &srcLen );
qglCompileShaderARB( m_hVShader );
if ( qglGetError() != GL_NO_ERROR ) {
QFXLog::Instance().Error( "Failed to compile vertex shader:\n\n%s\n", szvp );
PrintInfoLog( m_hVShader, program_name );
return;
}
qglGetObjectParameterivARB( m_hVShader, GL_OBJECT_COMPILE_STATUS_ARB, &objectStatus );
if ( !objectStatus ) {
QFXLog::Instance().Error( "Failed to compile vertex shader:\n\n%s\n", szvp );
PrintInfoLog( m_hVShader, program_name );
return;
}
}
if ( szfp ) {
qglGetError();
m_hFShader = qglCreateShaderObjectARB( GL_FRAGMENT_SHADER_ARB );
GLint srcLen = strlen( szfp );
qglShaderSourceARB( m_hFShader, 1, (const char**)&szfp, &srcLen);
qglCompileShaderARB( m_hFShader );
if ( qglGetError() != GL_NO_ERROR ) {
QFXLog::Instance().Error( "Failed to compile fragment shader:\n\n%s\n", szfp );
PrintInfoLog( m_hFShader, program_name );
return;
}
qglGetObjectParameterivARB( m_hFShader, GL_OBJECT_COMPILE_STATUS_ARB, &objectStatus );
if ( !objectStatus ) {
QFXLog::Instance().Error( "Failed to compile fragment shader:\n\n%s\n", szfp );
PrintInfoLog( m_hFShader, program_name );
return;
}
}
m_hProgram = qglCreateProgramObjectARB();
if ( szvp ) qglAttachObjectARB( m_hProgram, m_hVShader );
if ( szfp ) qglAttachObjectARB( m_hProgram, m_hFShader );
qglGetError();
qglLinkProgramARB( m_hProgram );
if ( qglGetError() != GL_NO_ERROR ) {
QFXLog::Instance().Error( "Failed to link shaders!\n\nVertex:\n%s\n\nFragment:\n%s\n", szvp ? szvp : "none", szfp ? szfp : "none" );
PrintInfoLog( m_hProgram, program_name );
return;
}
qglGetObjectParameterivARB( m_hProgram, GL_OBJECT_LINK_STATUS_ARB, &objectStatus );
if ( !objectStatus ) {
QFXLog::Instance().Error( "Failed to link shaders!\n\nVertex:\n%s\n\nFragment:\n%s\n", szvp ? szvp : "none", szfp ? szfp : "none" );
PrintInfoLog( m_hProgram, program_name );
return;
}
qglUseProgramObjectARB( m_hProgram );
//Get uniforms
for ( int c = 0; c < QFX_MAX_SHADER_UNIFORMS; c++ ) {
sprintf_s( nameBuffer, "Local%i", c );
m_iUniforms[c] = qglGetUniformLocationARB( m_hProgram, nameBuffer );
}
//Attach uniform textures
for ( int c = 0; c < QFX_MAX_SHADER_TEXTURES; c++ ) {
sprintf_s( nameBuffer, "Texture%i", c );
GLint texunitloc = qglGetUniformLocationARB( m_hProgram, nameBuffer );
if ( texunitloc != -1 ) qglUniform1iARB( texunitloc, c );
}
qglValidateProgramARB( m_hProgram );
qglGetObjectParameterivARB( m_hProgram, GL_OBJECT_VALIDATE_STATUS_ARB, &objectStatus );
if ( !objectStatus ) {
QFXLog::Instance().Error( "Failed to validate shaders!\n\nVertex:\n%s\n\nFragment:\n%s\n", szvp ? szvp : "none", szfp ? szfp : "none" );
PrintInfoLog( m_hProgram, program_name );
return;
}
qglUseProgramObjectARB( 0 );
m_bValid = true;
}
QFXShader :: ~QFXShader()
{
if ( m_hVShader ) {
qglDetachObjectARB( m_hProgram, m_hVShader );
qglDeleteObjectARB( m_hVShader );
}
if ( m_hFShader ) {
qglDetachObjectARB( m_hProgram, m_hFShader );
qglDeleteObjectARB( m_hFShader );
}
qglDeleteObjectARB( m_hProgram );
}
void QFXShader :: Bind( void )
{
qglUseProgramObjectARB( m_hProgram );
}
void QFXShader :: Unbind( void )
{
qglUseProgramObjectARB( 0 );
}
void QFXShader :: SetParameter4f( int param, float x, float y, float z, float w )
{
if ( unsigned( param ) >= QFX_MAX_SHADER_UNIFORMS ) {
QFXLog::Instance().Warning( "QFXShader::SetParameter4f: parameter index out of range (%i)\n", param );
return;
}
qglUniform4fARB( m_iUniforms[param], x, y, z, w );
}
void QFXShader :: SetParameter4fv( int param, float* v )
{
if ( unsigned( param ) >= QFX_MAX_SHADER_UNIFORMS ) {
QFXLog::Instance().Warning( "QFXShader::SetParameter4fv: parameter index out of range (%i)\n", param );
return;
}
qglUniform4fvARB( m_iUniforms[param], 4, v );
}
void QFXShader :: PrintInfoLog( GLhandleARB object, const char * program_name )
{
int logMaxLen;
qglGetObjectParameterivARB( object, GL_OBJECT_INFO_LOG_LENGTH_ARB, &logMaxLen );
if ( logMaxLen <= 0 )
return;
char *plog = new char[logMaxLen+1];
qglGetInfoLogARB( object, logMaxLen, NULL, plog );
if (strlen(plog)) {
char buff[1024];
sprintf( buff, "Compile log for '%s': %s\n", program_name, plog );
//QFXLog::Instance().Printf("Compile log: %s\n", plog);
MessageBox( NULL, buff, NULL, 0 );
}
delete [] plog;
}
-50
View File
@@ -1,50 +0,0 @@
/***************************************************************************
* Copyright (C) 2012, Chain Studios.
*
* This file is part of QeffectsGL source code.
*
* QeffectsGL source code 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.
*
* QeffectsGL source code 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 St, Fifth Floor, Boston, MA 02110-1301 USA
***************************************************************************/
#ifndef QFX_SHADER_H
#define QFX_SHADER_H
#define QFX_MAX_SHADER_UNIFORMS 8
#define QFX_MAX_SHADER_TEXTURES 8
class QFXShader
{
public:
QFXShader( const char *szvp, const char *szfp, const char *program_name );
~QFXShader();
bool IsValid( void ) { return m_bValid; }
void Bind( void );
void Unbind( void );
void SetParameter4f( int param, float x, float y, float z, float w );
void SetParameter4fv( int param, float* v );
private:
void PrintInfoLog( GLhandleARB object, const char *program_name );
private:
bool m_bValid;
GLhandleARB m_hProgram;
GLhandleARB m_hVShader;
GLhandleARB m_hFShader;
GLint m_iUniforms[QFX_MAX_SHADER_UNIFORMS];
};
#endif //QFX_SHADER_H
File diff suppressed because it is too large. Load diff
-561
View File
@@ -1,561 +0,0 @@
#ifndef _renderer_api_h
#define _renderer_api_h
#include <stdio.h>
#ifdef _CGAME_DLL
#include "cgamex86.h"
#else
#include "gamex86.h"
#endif
#ifdef WANT_OPENGL
#include "ogl\opengl_api.h"
#endif
#define QUAT_EPSILON 0.00001
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795f
#endif
#define random() ((rand () & 0x7fff) / ((float)0x7fff))
#define crandom() (2.0 * (random() - 0.5))
#define DEG2RAD( a ) ( ( (a) * M_PI ) / 180.0F )
#define RAD2DEG( a ) ( ( (a) * 180.0f ) / M_PI )
#define ANGLE2SHORT(x) ((int)((x)*65536/360) & 65535)
#define SHORT2ANGLE(x) ((x)*(360.0/65536))
#define SUBMAX( a, b ) ( a > b ? ( a - b ) : ( b - a ) )
#define SUBMIN( a, b ) ( a < b ? ( a - b ) : ( b - a ) )
/*#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
#define VectorSubtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])
#define VectorAdd(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])
#define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])
#define VectorScale(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))
#define VectorMA(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s))
#define VectorCompare(a,b) (((a)[0]==(b)[0])&&((a)[1]==(b)[1])&&((a)[2]==(b)[2]))
#define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0)
#define VectorNegate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])
#define VectorSet(v, x, y, z) ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))
#define Vector4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])*/
#define VectorInverse(a) ((a)[0]=-(a)[0],(a)[1]=-(a)[1],(a)[2]=-(a)[2])
#define PITCH 0
#define YAW 1
#define ROLL 2
#define RED 0
#define GREEN 1
#define BLUE 2
#define MAX_EFFECTS 10
#define MAX_EFFECTS_LENGTH 64
/* Animation flags */
#define ANIM_RANDOM 0x01
#define ANIM_DELTADRIVEN 0x02
#define ANIM_DONTREPEATE 0x03
#define ANIM_AUTOSTEPS_DOG 0x04
#define ANIM_DEFAULTANGLES 0x08
#define ANIM_NOTIMECHECK 0x10
#define ANIM_AUTOSTEPS_WALK 0x14
#define ANIM_AUTOSTEPS_RUN 0x1C
#define GLS_SRCBLEND_ZERO 0x00000001
#define GLS_SRCBLEND_ONE 0x00000002
#define GLS_SRCBLEND_DST_COLOR 0x00000003
#define GLS_SRCBLEND_ONE_MINUS_DST_COLOR 0x00000004
#define GLS_SRCBLEND_SRC_ALPHA 0x00000005
#define GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA 0x00000006
#define GLS_SRCBLEND_DST_ALPHA 0x00000007
#define GLS_SRCBLEND_ONE_MINUS_DST_ALPHA 0x00000008
#define GLS_SRCBLEND_ALPHA_SATURATE 0x00000009
#define GLS_SRCBLEND_BITS 0x0000000f
#define GLS_DSTBLEND_ZERO 0x00000010
#define GLS_DSTBLEND_ONE 0x00000020
#define GLS_DSTBLEND_SRC_COLOR 0x00000030
#define GLS_DSTBLEND_ONE_MINUS_SRC_COLOR 0x00000040
#define GLS_DSTBLEND_SRC_ALPHA 0x00000050
#define GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA 0x00000060
#define GLS_DSTBLEND_DST_ALPHA 0x00000070
#define GLS_DSTBLEND_ONE_MINUS_DST_ALPHA 0x00000080
#define GLS_DSTBLEND_BITS 0x000000f0
#define GLS_DEPTHMASK_TRUE 0x00000100
#define GLS_NODEPTH 0x00000200
#define GLS_DEPTH 0x00000300
#define GLS_POLYMODE_LINE 0x00001000
#define GLS_DEPTHTEST_DISABLE 0x00010000
#define GLS_DEPTHFUNC_EQUAL 0x00020000
#define GLS_ATEST_GT_0 0x10000000
#define GLS_ATEST_LT_80 0x20000000
#define GLS_ATEST_GE_80 0x40000000
#define GLS_ATEST_BITS 0x70000000
#define GLS_DEFAULT GLS_DEPTHMASK_TRUE
#define ELM_MODELS 0x004b56b3
#define ELM_WALLS 0x004b598e
#define ELM_FLAT 0x004b3993
#define ELM_ENTS 0x004b56b3
#define ELM_WORLD 0x004b598e
static const char *anim_cmd[] =
{
"weight",
"deltadriven",
"default_angles",
"notimecheck",
"crossblend",
"dontrepeate",
"random",
"autosteps_run",
"autosteps_walk",
"autosteps_dog",
};
static const char *effectName[MAX_EFFECTS] =
{
"bloom",
"blur",
"darkwhite",
"dof",
"invert",
"scenecolor",
"thermal",
"wallhack",
"wave",
};
qboolean __inline R_IsEffect(const char * fxName)
{
int i;
/* Check if the name is a valid effect name */
for(i=0;i<MAX_EFFECTS;i++)
{
if( _stricmp( fxName, effectName[ i ] ) == 0 )
return true;
}
return false;
}
typedef struct vvar_s
{
char *name;
int integer;
int integer_target;
float value;
float value_current;
float value_start;
vec3_t vector;
vec3_t vector_current;
vec3_t vector_start;
qboolean bProcessed;
} vvar_t;
typedef struct {
vvar_t *vvar;
const char *name;
const char *value;
vec4_t vector;
} regVis_t;
typedef struct effect_s
{
char effectName[MAX_EFFECTS_LENGTH];
float intensity;
vec3_t color;
vec3_t t_color;
vec3_t o_color;
float fadetime;
qboolean bRemove;
float param[2];
} effect_t;
typedef struct tikiFrame_s
{
vec3_t bounds[ 2 ];
vec3_t scale;
vec3_t offset;
vec3_t delta;
float radius;
float frameTime;
} tikiFrame_t;
typedef struct refDef_s
{
int x;
int y;
int width;
int height;
float fovX;
float fovY;
vec3_t viewOrg;
vec3_t viewAxis[3];
int time;
int rdFlags;
unsigned char areaMask[32];
float farplaneDistance;
float farplaneColor[3];
qboolean farplaneCull;
qboolean skyPortal;
float skyAlpha;
vec3_t skyOrigin;
vec3_t skyAxis[3];
} refDef_t;
typedef struct animation_s
{
unsigned char un1[0x184]; // 0x000
float weight; // 0x184
float crossblend; // 0x188
int animFlags; // 0x18C
} animation_t;
typedef struct bmodel_s
{
char un1[ 40 ];
void *lightmap;
bool haslightmap;
} bmodel_t;
typedef struct model_s
{
char un1[ 140 ];
bmodel_t *bmodel;
} model_t;
typedef struct debugLine_s
{
vec3_t start;
vec3_t end;
float color[ 3 ];
float alpha;
float width;
short unsigned int factor;
short unsigned int pattern;
} debugLine_t;
typedef struct debugString_s
{
char text[ MAX_QPATH ];
vec3_t pos;
float scale;
vec4_t color;
} debugString_t;
typedef struct polyVert_s
{
float xyz[ 3 ];
float st[ 2 ];
unsigned char modulate[ 4 ];
} polyVert_t;
typedef enum dlightType_e
{
LENSFLARE = 1,
VIEWLENSFLARE,
ADDITIVE = 4
} dlightType_t;
typedef enum stereoFrame_e
{
STEREO_CENTER,
STEREO_LEFT,
STEREO_RIGHT
} stereoFrame_t;
typedef struct letterLoc_s
{
vec2_t pos;
vec2_t size;
} letterLoc_t;
typedef struct fontHeader_s
{
int indirection[ 256 ];
letterLoc_t locations[ 256 ];
char name[ MAX_QPATH ];
float height;
float aspectRatio;
void *shader;
int trHandle;
} fontHeader_t;
typedef struct media_s
{
qhandle_t backTileShader;
qhandle_t lagometerShader;
qhandle_t shadowMarkShader;
qhandle_t footShadowMarkShader;
qhandle_t wakeMarkShader;
qhandle_t pausedShader;
qhandle_t levelExitShader;
qhandle_t zoomOverlayShader;
qhandle_t kar98TopOverlayShader;
qhandle_t kar98BottomOverlayShader;
qhandle_t binocularsOverlayShader;
fontHeader_t *hudDrawFont;
fontHeader_t *attackerFont;
fontHeader_t *objectiveFont;
qhandle_t objectivesBackShader;
qhandle_t checkedBoxShader;
qhandle_t uncheckedBoxShader;
} media_t;
typedef void( *GL_State_f )( int state );
extern GL_State_f GL_State;
typedef void( *GL_Bind_f )( void * image );
extern GL_Bind_f GL_Bind;
typedef void( *GL_Setup_f )( void );
extern GL_Setup_f GL_Setup;
typedef struct refImport_s
{
void ( *Printf )( int type, const char *format, ... );
void ( *Error )( errorParm_t errorCode, const char *format, ... );
int ( *Milliseconds )( );
char * ( *LV_ConvertString )( const char *string );
void ( *Hunk_Clear )( );
void * ( *Hunk_Alloc )( size_t size );
void * ( *Hunk_AllocateTempMemory )( size_t size );
void ( *Hunk_FreeTempMemory )( void *buffer );
void * ( *Malloc )( size_t size );
void ( *Free )( void *ptr );
void ( *Clear )( );
cvar_t * ( *Cvar_Get )( char *varName, char *varValue, int varFlags );
void ( *Cvar_Set )( char *varName, char *varValue );
void ( *Cvar_SetDefault )( cvar_t *var, char *varValue );
void ( *Cmd_AddCommand )( char *cmdName, xcommand_t cmdFunction );
void ( *Cmd_RemoveCommand )( char *cmdName );
int ( *Argc )( );
char * ( *Argv )( int arg );
void ( *Cmd_ExecuteText )( cbufExec_t execWhen, char *text );
void ( *CM_DrawDebugSurface )( void ( *drawPoly )( ) );
int ( *FS_OpenFile )( char *qpath, fsMode_t mode );
int ( *FS_Read )( void *buffer, int len, fileHandle_t fileHandle );
void ( *FS_CloseFile )( fileHandle_t fileHandle );
int ( *FS_Seek )( fileHandle_t fileHandle, long int offset, fsOrigin_t origin );
int ( *FS_FileIsInPAK )( char *fileName, int *checksum );
int ( *FS_ReadFile )( char *qpath, void **buffer );
int ( *FS_ReadFileEx )( char *qpath, void **buffer, qboolean quiet );
void ( *FS_FreeFile )( void *buffer );
const char ** ( *FS_ListFiles )( const char *qpath, const char *extension, qboolean wantSubs, int *numFiles );
void ( *FS_FreeFileList )( char **list );
int ( *FS_WriteFile )( char *qpath, void *buffer, int size );
qboolean ( *FS_FileExists )( char *file );
void ( *CM_BoxTrace )( trace_t *results, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, int model, int brushMask, int cylinder );
int ( *CM_TerrainSquareType )( int terrainPatch, int i, int j );
char * ( *CM_EntityString )( );
char * ( *CM_MapTime )( );
int ( *CG_PermanentMark )( vec3_t origin, vec3_t dir, float orientation, float sScale, float tScale, float red, float green, float blue, float alpha, qboolean doLighting, float sCenter, float tCenter, markFragment_t *markFragments, void *polyVerts );
int ( *CG_PermanentTreadMarkDecal )( treadMark_t *treadMark, qboolean startSegment, qboolean doLighting, markFragment_t *markFragments, void *polyVerts );
int ( *CG_PermanentUpdateTreadMark )( treadMark_t *treadMark, float alpha, float minSegment, float maxSegment, float maxOffset, float texScale );
void ( *CG_ProcessInitCommands )( dtiki_t *tiki, refEntity_t *ent );
void ( *CG_EndTiki )( dtiki_t *tiki );
void ( *SetPerformanceCounters )( int totalTris, int totalVerts, int totalTexels, int worldTris, int worldVerts, int characterLights );
debugLine_t **debugLines;
int *numDebugLines;
debugString_t **debugStrings;
int *numDebugStrings;
orientation_t ( *TIKI_OrientationInternal )( dtiki_t *tiki, int entNum, int tagNum, float scale );
qboolean ( *TIKI_IsOnGroundInternal )( dtiki_t *tiki, int entNum, int tagNum, float thresHold );
void ( *TIKI_SetPoseInternal )( void *skeletor, frameInfo_t *frameInfo, int *boneTag, vec4_t boneQuat[4], float actionWeight );
void * ( *TIKI_Alloc )( int size );
float ( *GetRadiusInternal )( dtiki_t *tiki, int entNum, float scale );
float ( *GetCentroidRadiusInternal )( dtiki_t *tiki, int entNum, float scale, vec3_t centroid );
void ( *GetFrameInternal )( dtiki_t *tiki, int entNum, skelAnimFrame_t *newFrame );
} refImport_t;
typedef struct refExport_s
{
void ( *Shutdown )( );
void ( *BeginRegistration )( glconfig_t *glConfigOut );
qhandle_t ( *RegisterModel )( const char *name );
qhandle_t ( *SpawnEffectModel )( const char *name, vec3_t pos, vec3_t axis[3] );
qhandle_t ( *RegisterServerModel )( const char *name );
void ( *UnregisterServerModel )( qhandle_t model );
qhandle_t ( *RegisterShader )( const char *name );
qhandle_t ( *RegisterShaderNoMip )( const char *name );
qhandle_t ( *RefreshShaderNoMip )( const char *name );
void ( *EndRegistration )( );
void ( *FreeModels )( );
void ( *SetWorldVisData )( unsigned char *vis );
void ( *LoadWorld )( char *name );
void ( *PrintBSPFileSizes )( );
int ( *MapVersion )( );
void ( *ClearScene )( );
void ( *AddRefEntityToScene )( refEntity_t *ent, int parentEntityNumber );
void ( *AddRefSpriteToScene )( refEntity_t *ent );
qboolean ( *AddPolyToScene )( qhandle_t hShader, int numVerts, polyVert_t *verts, int renderFx );
void ( *AddTerrainMarkToScene )( int terrainIndex, qhandle_t hShader, int numVerts, polyVert_t *verts, int renderfx );
void ( *AddLightToScene )( vec3_t org, float intensity, float r, float g, float b, dlightType_t type );
void ( *RenderScene )( refDef_t *fd );
refEntity_t * ( *GetRenderEntity )( int entityNumber );
void ( *SavePerformanceCounters )( );
void ( *SetColor )( vec4_t color );
void ( *Set2DWindow )( int x, int y, int w, int h, float left, float right, float bottom, float top, float n, float f );
void ( *DrawStretchPic )( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );
void ( *DrawTilePic )( float x, float y, float w, float h, qhandle_t hShader );
void ( *DrawTilePicOffset )( float x, float y, float w, float h, qhandle_t hShader, int offsetX, int offsetY );
void ( *DrawTrianglePic )( vec2_t *points, vec2_t *texCoords, qhandle_t hShader );
void ( *DrawBackground )( int cols, int rows, int bgr, unsigned char *data );
void ( *DrawStretchRaw )( int x, int y, int w, int h, int cols, int rows, int components, unsigned char *data );
void ( *DebugLine )( vec3_t start, vec3_t end, float r, float g, float b, float alpha );
void ( *DrawBox )( float x, float y, float w, float h );
void ( *AddBox )( float x, float y, float w, float h );
void ( *BeginFrame )( stereoFrame_t stereoFrame );
void ( *Scissor )( int x, int y, int width, int height );
void ( *DrawLineLoop )( vec2_t *points, int count, int stippleFactor, int stippleMask );
void ( *EndFrame )( int *frontEndMsec, int *backEndMsec );
int ( *MarkFragments )( int numPoints, vec3_t *points, vec3_t projection, int maxPoints, float *pointBuffer, int maxFragments, markFragment_t *fragmentBuffer, float radiusSquared );
int ( *MarkFragmentsForInlineModel )( clipHandle_t bmodel, vec3_t angles, vec3_t origin, int numPoints, vec3_t *points, vec3_t projection, int maxPoints, float *pointBuffer, int maxFragments, markFragment_t *fragmentBuffer, float radiusSquared );
void ( *GetInlineModelBounds )( int index, vec3_t mins, vec3_t maxs );
void ( *GetLightingForDecal )( vec3_t light, vec3_t facing, vec3_t origin );
void ( *GetLightingForSmoke )( vec3_t light, vec3_t origin );
int ( *R_GatherLightSources )( vec3_t pos, vec3_t *lightPos, vec3_t *lightIntensity, int maxLights );
void ( *ModelBounds )( qhandle_t handle, vec3_t mins, vec3_t maxs );
float ( *ModelRadius )( qhandle_t handle );
dtiki_t * ( *R_Model_GetHandle )( qhandle_t handle );
void ( *DrawString )( fontHeader_t *font, char *text, float x, float y, int maxLen, qboolean virtualScreen );
float ( *GetFontHeight )( fontHeader_t *font );
float ( *GetFontStringWidth )( fontHeader_t *font, const char *string );
fontHeader_t * ( *LoadFont )( char *name );
void ( *SwipeBegin )( float thisTime, float life, qhandle_t hShader );
void ( *SwipePoint )( vec3_t point1, vec3_t point2, float time );
void ( *SwipeEnd )( );
void ( *SetRenderTime )( int t );
float ( *Noise )( vec3_t vec, int len );
qboolean ( *SetMode )( int mode, glconfig_t *glConfig );
void ( *SetFullscreen )( qboolean fullScreen );
int ( *GetShaderWidth )( qhandle_t hShader );
int ( *GetShaderHeight )( qhandle_t hShader );
char * ( *GetGraphicsInfo )( );
void ( *ForceUpdatePose )( refEntity_t *model );
orientation_t ( *TIKI_Orientation )( refEntity_t *model, int tagNum );
qboolean ( *TIKI_IsOnGround )( refEntity_t *model );
void ( *SetFrameNumber )( int frameNumber );
} refExport_t;
extern refImport_t ri;
extern refExport_t re;
extern effect_t * effect_list[MAX_EFFECTS];
extern cvar_t *r_debug;
extern cvar_t *r_dof;
extern cvar_t *r_texFilterAniso;
extern cvar_t *r_tweakBlurX;
extern cvar_t *r_tweakBlurY;
extern cvar_t *r_tweakBlurPasses;
extern cvar_t *r_glowEnable;
extern cvar_t *r_glowQuality;
extern cvar_t *r_glowSamples;
extern cvar_t *r_ssao;
extern cvar_t *r_autoluminance;
extern cvar_t *r_fxaa;
extern cvar_t *r_test_color;
extern cvar_t *r_test_bump;
#ifdef _CGAME_DLL
#if 0
// vision-specific variables
extern vvar_t r_glow;
extern vvar_t r_glowRadius0;
extern vvar_t r_glowRadius1;
extern vvar_t r_glowBloomCutoff;
extern vvar_t r_glowBloomDesaturation;
extern vvar_t r_glowBloomIntensity0;
extern vvar_t r_glowBloomIntensity1;
extern vvar_t r_glowBloomStreakX;
extern vvar_t r_glowBloomStreakY;
extern vvar_t r_filmEnable;
extern vvar_t r_filmContrast;
extern vvar_t r_filmBrightness;
extern vvar_t r_filmDesaturation;
extern vvar_t r_filmSaturation;
extern vvar_t r_filmHue;
extern vvar_t r_filmBleach;
extern vvar_t r_filmMidStart;
extern vvar_t r_filmMidEnd;
extern vvar_t r_filmLightTint;
extern vvar_t r_filmMidTint;
extern vvar_t r_filmDarkTint;
extern vvar_t r_distortionEnable;
extern vvar_t r_distortionRadius;
extern vvar_t r_distortionScale;
#endif
//void R_DoPostProcessing(refDef_t *fd);
#ifdef WANT_OPENGL
void WINAPI _glBegin(GLenum mode);
void WINAPI _glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
void WINAPI _glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
#endif
effect_t * R_GetEffectById(int ID);
effect_t * R_GetEffectByName(const char * fxName);
void R_Draw3D();
void R_SetShader( int ent_num, const char * shader, qboolean fDefault );
void R_AddRefEntityToScene( refEntity_t *ent, int parentEntityNumber );
void R_AddRefSpriteToScene( refEntity_t *ent );
void R_PostProcessEffect(const char * effectName, float intensity, vec3_t colors, float fadetime, qboolean bAddEffect, float parameters[2]);
void R_ProcessEffectsFade(int frametime);
void R_RemoveEffect(effect_t * effect);
void R_Shutdown(void);
void R_SetSceneColor( vec3_t light, vec3_t dark );
void R_SetSceneColor2(float intensity, vec3_t color);
void R_SetSkyColor( vec3_t color );
qboolean R_ProcessVisionVar( const char * variable, const char * value );
void R_ProcessBlur( float blur_level, float fade_time );
void R_ProcessVision( str vision_name, float fade_time, float phase = 0.0f, str type = "vision" );
#endif
#endif
-15
View File
@@ -1,15 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by Script1.rc
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
-156
View File
@@ -1,156 +0,0 @@
/*
* CAnimate.cpp
*
* DESCRIPTION : Client animate. Enable entities animations
*/
#include "canimate.h"
#include "clientgamecommand.h"
Event EV_Animate_Anim
(
"anim",
EV_DEFAULT,
"s",
"animName",
"Exec anim commands on client.",
EV_NORMAL
);
Animate::Animate()
{
}
Animate::~Animate()
{
}
void Animate::Archive( Archiver &arc )
{
Entity::Archive( arc );
}
void Animate::Think()
{
int num_playing = 0;
if( !tiki ) {
return Entity::Think();
}
for( int i = 0; i < GetNumFrames(); i++ )
{
float max_time = cgi.Anim_Time( tiki, frame[ i ].index );
if( frame[ i ].time < max_time )
{
frame[ i ].time += cg->frametime;
num_playing++;
}
else
{
frame[ i ].time = max_time;
}
}
// Optimize performances
if( !num_playing && this->classinfo() == Animate::classinfostatic() ) {
turnThinkOff();
}
Entity::Think();
}
void Animate::PlayAnim( const char *name, int index )
{
int num = cgi.Anim_NumForName( tiki, name );
if( num != -1 ) {
PlayAnim( num, index );
}
}
void Animate::PlayAnim( int num, int index )
{
float frametime;
if( index >= MAX_FRAMEINFOS ) {
return;
}
if( index >= numframes )
{
numframes++;
frame = ( frameInfo_t * )realloc( frame, sizeof( frameInfo_t ) * numframes );
}
frame[ index ].index = num;
frame[ index ].time = 0.0f;
frame[ index ].weight = 1.0f;
frametime = cgi.Anim_Frametime( tiki, num );
if( cgi.Anim_HasCommands( tiki, num ) )
{
float time = -frametime;
// Exec anim commands
// They will be executed in the context of the commandManager
for( int i = 0; i < cgi.Anim_NumFrames( tiki, num ); i++ )
{
tiki_cmd_t cmds;
Event *ev;
time += frametime;
if( !cgi.Frame_Commands( tiki, num, i, &cmds ) ) {
continue;
}
for( int k = 0; k < cmds.num_cmds; k++ )
{
cgi.Printf( "args = '%s'\n", cmds.cmds[ k ].args[ 0 ] );
ev = new Event( cmds.cmds[ k ].args[ 0 ] );
for( int c = 1; c < cmds.cmds[ k ].num_args; c++ )
{
const char *argument = cmds.cmds[ k ].args[ c ];
ev->AddString( cmds.cmds[ k ].args[ c ] );
}
commandManager->PostEvent( ev, frametime, 0 );
}
}
}
}
void Animate::SetTime( int index, float time )
{
if( index >= numframes ) {
return;
}
frame[ index ].time = time;
turnThinkOn();
}
//=== SCRIPT ===\\
void Animate::ForwardExec( Event *ev )
{
str name = ev->GetString( 1 );
PlayAnim( name, 0 );
SetTime( 0, 0.0f );
}
CLASS_DECLARATION( Entity, Animate, NULL )
{
{ &EV_Animate_Anim, &Animate::ForwardExec },
{ NULL, NULL },
};
-25
View File
@@ -1,25 +0,0 @@
#ifndef __CANIMATE_H__
#define __CANIMATE_H__
#include "centity.h"
class Animate : public Entity
{
public:
CLASS_PROTOTYPE( Animate );
virtual void Archive( Archiver &arc );
Animate();
~Animate();
virtual void Think();
void PlayAnim( const char *name, int index );
void PlayAnim( int num, int index );
void SetTime( int index, float time );
void ForwardExec( Event *ev );
};
#endif /* __CANIMATE_H__ */
-449
View File
@@ -1,449 +0,0 @@
/*
* Entity.cpp
*
* DESCRIPTION : Client-side entity
*/
#include "centity.h"
#include "archive.h"
Container< SafePtr< Entity > > s_entities;
Event EV_Entity_Attach
(
"attach",
EV_DEFAULT,
"esIV",
"parent tagname use_angles offset",
"attach this entity to the parent's legs tag called tagname",
EV_NORMAL
);
Event EV_Entity_Detach
(
"detach",
EV_DEFAULT,
NULL,
NULL,
"detach this entity from its parent.",
EV_NORMAL
);
Event EV_Entity_GetModel
(
"model",
EV_DEFAULT,
NULL,
NULL,
"Gets the model.",
EV_RETURN
);
Event EV_Entity_Getter_GetModel
(
"model",
EV_DEFAULT,
NULL,
NULL,
"Gets the model.",
EV_GETTER
);
Event EV_Entity_GetScale
(
"scale",
EV_DEFAULT,
NULL,
NULL,
"Gets the scale.",
EV_GETTER
);
Event EV_Entity_SetModel
(
"model",
EV_DEFAULT,
"s",
"modelName",
"Sets the model to modelName.",
EV_NORMAL
);
Event EV_Entity_SetScale
(
"scale",
EV_DEFAULT,
"f",
"scale",
"Sets the scale.",
EV_SETTER
);
Event EV_Entity_Setter_SetModel
(
"model",
EV_DEFAULT,
"s",
"modelName",
"Sets the model to modelName.",
EV_SETTER
);
Event EV_Entity_SetSize
(
"setsize",
EV_DEFAULT,
"vv",
"mins maxs",
"Set the bounding box of the entity to mins and maxs.",
EV_NORMAL
);
Event EV_Touch
(
"doTouch",
EV_CODEONLY,
"e",
"touchingEntity",
"sent to entity when touched.",
EV_NORMAL
);
Entity * CL_GetCEntity( int ent_num )
{
// Iterate through simple client entities
for( int i = 0; i < s_entities.NumObjects(); i++ )
{
Entity * ent = ( Entity * )s_entities[ i ];
if( !checkInheritance( &Entity::ClassInfo, ent->classinfo() ) ) {
continue;
}
int entnum = ent->GetNumber();
if( entnum != -1 && entnum == ent_num ) {
return ent;
}
}
return NULL;
}
centity_t *CL_GetEntity( int ent_num )
{
entityState_t *ce = NULL;
int i;
for( i = 0; i < cg->activeSnapshots[ 0 ].numEntities; i++ )
{
if( cg->activeSnapshots[ 0 ].entities[ i ].number == ent_num ) {
ce = &cg->activeSnapshots[ 0 ].entities[ i ];
}
}
return ( centity_t * )ce;
}
void CL_ProcessCEntities()
{
// Iterate through client entities
for( int i = s_entities.NumObjects(); i > 0; i-- )
{
Entity *ent = s_entities.ObjectAt( i );
if( !checkInheritance( &Entity::ClassInfo, ent->classinfo() ) ) {
continue;
}
if( ent->CanThink() ) {
ent->Think();
}
}
}
Entity::Entity()
{
cent = &cg_entities[ 0 ];
centity = &cg_entities[ 0 ];
model = "";
modelhandle = 0;
scale = 1.f;
renderFx = 0;
tiki = NULL;
frame = new frameInfo_t[ 1 ];
numframes = 1;
entnum = -1;
frame[ 0 ].index = 0;
frame[ 0 ].time = 0.f;
frame[ 0 ].weight = 1.0f;
//turnThinkOn();
absmin = absmax = mins = maxs = vec_zero;
s_entities.AddObject( this );
}
Entity::~Entity()
{
if( frame ) {
delete[] frame;
}
numframes = 0;
s_entities.RemoveObject( this );
}
bool Entity::IsTouching( Entity *ent )
{
return ent->absmin[ 0 ] <= absmax[ 0 ]
&& ent->absmin[ 1 ] <= absmax[ 1 ]
&& ent->absmin[ 2 ] <= absmax[ 2 ]
&& absmin[ 0 ] <= ent->absmax[ 0 ]
&& absmin[ 1 ] <= ent->absmax[ 1 ]
&& absmin[ 2 ] <= ent->absmax[ 2 ];
}
float Entity::getScale()
{
return scale;
}
qboolean Entity::inRadius( Vector org, float rad )
{
if( Vector::Distance( origin, org ) <= rad ) {
return true;
} else {
return false;
}
}
void Entity::setModel( const char *name )
{
model = name;
modelhandle = cgi.R_RegisterModel( name );
tiki = cgi.R_Model_GetHandle( modelhandle );
}
void Entity::setOrigin( Vector origin )
{
this->origin = origin;
absmin = origin + mins;
absmax = origin + maxs;
}
void Entity::setScale( float s )
{
scale = s;
}
void Entity::Think()
{
}
void Entity::Archive( Archiver &arc )
{
SimpleEntity::Archive( arc );
arc.ArchiveBoolean( &fShader );
if( fShader )
{
arc.ArchiveString( &shader );
if( arc.Loading() ) {
customshader = cgi.R_RegisterShader( shader );
}
}
arc.ArchiveBoolean( &canThink );
arc.ArchiveFloat( &scale );
arc.ArchiveInteger( &entnum );
arc.ArchiveInteger( &renderFx );
arc.ArchiveString( &model );
}
frameInfo_t *Entity::GetFrameInfo( int index )
{
if( index >= numframes ) {
return NULL;
} else {
return &frame[ index ];
}
}
int Entity::GetNumFrames()
{
return numframes;
}
void Entity::GetTag( const char *tagname, orientation_t *orient )
{
refEntity_t ref;
if( tiki == NULL ) {
return;
}
int num = cgi.Tag_NumForName( tiki, tagname );
if( num == -1 ) {
return;
}
memset( &ref, 0, sizeof( refEntity_t ) );
VectorCopy( origin, ref.origin );
MatrixToEulerAngles( ref.axis, angles );
ref.reType = RT_MODEL;
ref.scale = scale;
ref.hModel = modelhandle;
ref.hOldModel = modelhandle;
ref.tiki = tiki;
ref.entityNumber = 0;
ref.actionWeight = 1.0f;
for( int i = 0; i < GetNumFrames(); i++ )
{
frameInfo_t *frame = GetFrameInfo( i );
ref.frameInfo[ i ].index = frame->index;
ref.frameInfo[ i ].time = frame->time;
ref.frameInfo[ i ].weight = frame->weight;
}
//cgi.TIKI_Orientation( orient, &ref, num );
*orient = re.TIKI_Orientation( &ref, num );
}
void Entity::AssignNumber( int ent_num )
{
if( entnum == -1 ) {
entnum = ent_num;
}
}
int Entity::GetNumber()
{
return entnum;
}
qboolean Entity::CanThink()
{
return canThink;
}
void Entity::turnThinkOn()
{
canThink = true;
}
void Entity::turnThinkOff()
{
canThink = false;
}
void Entity::SetShader( const char *name )
{
if( name == NULL )
{
fShader = false;
shader = "";
return;
}
fShader = true;
customshader = cgi.R_RegisterShader( name );
shader = name;
}
//=== SCRIPT ===\\
void Entity::EventAttach( Event *ev )
{
Entity *parent = ev->GetEntity( 1 );
str tagname = ev->GetString( 2 );
int use_angles;
Vector offset;
if( ev->NumArgs() > 2 ) {
use_angles = ev->GetInteger( 3 );
} else {
use_angles = 1;
}
if( ev->NumArgs() > 3 ) {
offset = ev->GetVector( 4 );
} else {
offset = vec_zero;
}
attached = parent;
attached_tagname = tagname;
attached_use_angles = use_angles;
attached_offset = offset;
}
void Entity::EventDetach( Event *ev )
{
attached = NULL;
}
void Entity::EventGetModel( Event *ev )
{
ev->AddString( model );
}
void Entity::EventGetScale( Event *ev )
{
ev->AddFloat( getScale() );
}
void Entity::EventSetScale( Event *ev )
{
setScale( ev->GetFloat( 1 ) );
}
void Entity::EventSetModel( Event *ev )
{
str name = ev->GetString( 1 );
setModel( name );
}
void Entity::EventSetSize( Event *ev )
{
mins = ev->GetVector( 1 );
maxs = ev->GetVector( 2 );
setOrigin( origin );
}
CLASS_DECLARATION( SimpleEntity, Entity, NULL )
{
{ &EV_Entity_Attach, &Entity::EventAttach },
{ &EV_Entity_Detach, &Entity::EventDetach },
{ &EV_Entity_GetModel, &Entity::EventGetModel },
{ &EV_Entity_GetScale, &Entity::EventGetScale },
{ &EV_Entity_Getter_GetModel, &Entity::EventGetModel },
{ &EV_Entity_SetModel, &Entity::EventSetModel },
{ &EV_Entity_SetScale, &Entity::EventSetScale },
{ &EV_Entity_Setter_SetModel, &Entity::EventSetModel },
{ &EV_Entity_SetSize, &Entity::EventSetSize },
{ NULL, NULL }
};
-85
View File
@@ -1,85 +0,0 @@
#ifndef __CENTITY_H__
#define __CENTITY_H__
#include "simpleentity.h"
#define MT_PHYSICS (1<<0) // This entity has physics
extern Event EV_Touch;
class Entity : public SimpleEntity {
public:
int entnum;
centity_t *centity;
qboolean fShader;
qhandle_t customshader;
str shader;
str model;
qhandle_t modelhandle;
dtiki_t *tiki;
int renderFx;
float scale;
int moveType;
SafePtr< Entity > attached;
str attached_tagname;
int attached_use_angles;
Vector attached_offset;
Vector absmin, absmax;
Vector mins, maxs;
private:
qboolean canThink;
protected:
frameInfo_t *frame;
int numframes;
public:
CLASS_PROTOTYPE( Entity );
virtual void Archive( Archiver &arc );
Entity();
virtual ~Entity();
frameInfo_t *GetFrameInfo( int index );
int GetNumFrames();
void GetTag( const char *tagname, orientation_t *orient );
virtual void Think();
bool IsTouching( Entity *ent );
float getScale();
qboolean inRadius( Vector org, float rad );
void setModel( const char *name );
virtual void setOrigin( Vector origin );
void setScale( float scale );
void AssignNumber( int ent_num );
qboolean CanThink( void );
int GetNumber( void );
void SetShader( const char *name );
void turnThinkOn( void );
void turnThinkOff( void );
void EventAttach( Event *ev );
void EventDetach( Event *ev );
void EventGetModel( Event *ev );
void EventGetScale( Event *ev );
void EventSetModel( Event *ev );
void EventSetScale( Event *ev );
void EventSetSize( Event *ev );
};
Entity * CL_GetCEntity( int ent_num );
centity_t * CL_GetEntity( int ent_num );
void CL_ProcessCEntities();
extern Container< SafePtr< Entity > > s_entities;
#endif /* __CENTITY_H__ */
@@ -1,353 +0,0 @@
/*
* ClientGameCommandManager.cpp
*
* DESCRIPTION : Client Game Command Manager
*/
#include "clientgamecommand.h"
#include "cgame/cl_sound.h"
#include "archive.h"
uintptr_t *sndDriver = ( uintptr_t * )0x7F5D74;
typedef void( __cdecl *AIL_CLOSE_STREAM )( void *stream );
typedef void* ( __cdecl *AIL_OPEN_STREAM )( uintptr_t soundDriver, const char *pFilename, int channel );
typedef void ( __cdecl *AIL_SET_STREAM_LOOP_COUNT )( void *stream, int count );
typedef void( __cdecl *AIL_SET_STREAM_PLAYBACK_RATE )( void *stream, int rate );
typedef void( __cdecl *AIL_SET_STREAM_POSITION )( void *stream, int position );
typedef void( __cdecl *AIL_SET_STREAM_VOLUME )( void *stream, int volume );
typedef void ( __cdecl *AIL_START_STREAM )( void *stream );
typedef int( __cdecl *AIL_STREAM_PLAYBACK_RATE )( void *stream );
typedef int( __cdecl *AIL_STREAM_POSITION )( void *stream );
typedef int ( __cdecl *AIL_STREAM_STATUS )( void *stream );
typedef char * ( __cdecl *GETFILEPATH )( const char *game_path, const char *path, const char *filename );
AIL_CLOSE_STREAM AIL_close_stream = ( AIL_CLOSE_STREAM )0x00486C80;
AIL_OPEN_STREAM AIL_open_stream = ( AIL_OPEN_STREAM )0x00486C20;
AIL_SET_STREAM_LOOP_COUNT AIL_set_stream_loop_count = ( AIL_SET_STREAM_LOOP_COUNT )0x00487030;
AIL_SET_STREAM_PLAYBACK_RATE AIL_set_stream_playback_rate = ( AIL_SET_STREAM_PLAYBACK_RATE )0x00486E70;
AIL_SET_STREAM_POSITION AIL_set_stream_position = ( AIL_SET_STREAM_POSITION )0x00487100;
AIL_SET_STREAM_VOLUME AIL_set_stream_volume = ( AIL_SET_STREAM_VOLUME )0x00486EE0;
AIL_START_STREAM AIL_start_stream = ( AIL_START_STREAM )0x00486DA0;
AIL_STREAM_PLAYBACK_RATE AIL_stream_playback_rate = ( AIL_STREAM_PLAYBACK_RATE )0x00487230;
AIL_STREAM_POSITION AIL_stream_position = ( AIL_STREAM_POSITION )0x004873E0;
AIL_STREAM_STATUS AIL_stream_status = ( AIL_STREAM_STATUS )0x004871E0;
GETFILEPATH GetFilePath = ( GETFILEPATH )0x00450840;
char *gameDir = ( char * )0x00EC4EE0;
Container< LocalSound * > localSounds;
ClientGameCommandManager *commandManager = ( ClientGameCommandManager * )0x30117B90;
ClientSpecialEffectsManager *sfxManager = ( ClientSpecialEffectsManager * )0x3026AB78;
Event EV_LocalSound_Think
(
"localsound_think",
EV_CODEONLY,
NULL,
NULL,
"Internal event",
EV_NORMAL
);
LocalSound::LocalSound( str n, qboolean l )
{
path = GetFilePath( fs_basepath->string, gameDir, n );
stream = AIL_open_stream( *sndDriver, path, 0 );
name = n;
stopping = false;
loop = l;
if( loop ) {
AIL_set_stream_loop_count( stream, 0 );
} else {
AIL_set_stream_loop_count( stream, 1 );
}
volume = 0.0f;
rate = 1.0f;
localSounds.AddObject( this );
}
LocalSound::LocalSound()
{
stream = NULL;
stopping = false;
loop = false;
volume = 0.0f;
rate = 1.0f;
localSounds.AddObject( this );
}
LocalSound::~LocalSound()
{
CancelEventsOfType( &EV_LocalSound_Think );
if( stream ) {
AIL_close_stream( stream );
}
localSounds.RemoveObject( this );
}
void LocalSound::Archive( Archiver &arc )
{
Listener::Archive( arc );
arc.ArchiveString( &name );
arc.ArchiveBoolean( &stopping );
arc.ArchiveBoolean( &loop );
if( arc.Saving() ) {
position = AIL_stream_position( stream );
}
arc.ArchiveInteger( &position );
arc.ArchiveFloat( &volume );
arc.ArchiveFloat( &start_volume );
arc.ArchiveFloat( &target_volume );
arc.ArchiveFloat( &rate );
arc.ArchiveObject( &timer );
if( arc.Loading() )
{
path = GetFilePath( fs_basepath->string, gameDir, name );
stream = AIL_open_stream( *sndDriver, path, 0 );
if( stream )
{
AIL_start_stream( stream );
if( loop ) {
AIL_set_stream_loop_count( stream, 0 );
}
else {
AIL_set_stream_loop_count( stream, 1 );
}
AIL_set_stream_position( stream, position );
Event *ev = new Event( &EV_LocalSound_Think );
ProcessEvent( ev );
}
}
}
str LocalSound::GetName()
{
return name;
}
void LocalSound::Play( float time, float v )
{
stopping = false;
start_volume = volume;
if( time <= 0.0f ) {
volume = v;
} else {
volume = 0.0f;
AIL_set_stream_volume( stream, 0 );
}
target_volume = v;
timer.SetTime( time );
timer.Enable();
start_rate = 1.0f;
target_rate = 1.0f;
rate = 1.0f;
if( stream )
{
AIL_start_stream( stream );
baserate = AIL_stream_playback_rate( stream );
Event *ev = new Event( &EV_LocalSound_Think );
ProcessEvent( ev );
}
}
void LocalSound::Stop( float time )
{
if( time <= 0.0f )
{
delete this;
return;
}
start_volume = volume;
timer.SetTime( time );
timer.Enable();
stopping = true;
}
void LocalSound::SetRate( float r, float time )
{
target_rate = r;
start_rate = rate;
timer_rate.SetTime( time );
timer_rate.Enable();
if( time <= 0.0f )
{
rate = r;
if( stream )
{
int ra = ( int )( ( float )baserate * rate );
AIL_set_stream_playback_rate( stream, ra );
}
}
}
void LocalSound::Think( Event *ev )
{
if( stopping ) {
volume = timer.LerpValue( start_volume, 0.0f );
}
AIL_set_stream_volume( stream, ( int )( volume * s_volume->value * *sound_global_volume * 100.0f ) );
if( !timer_rate.Done() ) {
rate = timer_rate.LerpValue( start_rate, target_rate );
}
int r = ( int )( ( float )baserate * rate );
AIL_set_stream_playback_rate( stream, r );
if( ( stopping && timer.Done() ) || AIL_stream_status( stream ) != STREAM_PLAYING )
{
CancelEventsOfType( &EV_LocalSound_Think );
delete this;
return;
}
if( !stopping ) {
volume = timer.LerpValue( start_volume, target_volume );
}
CancelEventsOfType( &EV_LocalSound_Think );
PostEvent( EV_LocalSound_Think, level.frametime, 0 );
}
CLASS_DECLARATION( Listener, LocalSound, NULL )
{
{ &EV_LocalSound_Think, &LocalSound::Think },
{ NULL, NULL }
};
void ClientGameCommandManager::CleanUp()
{
Container< LocalSound * > local = localSounds;
for( int i = 0; i < local.NumObjects(); i++ )
{
LocalSound *localSound = local[ i ];
delete localSound;
}
localSounds.FreeObjectList();
}
void ClientGameCommandManager::ArchiveFunction( Archiver &arc )
{
int num = localSounds.NumObjects();
arc.ArchiveInteger( &num );
if( arc.Saving() )
{
for( int i = 0; i < num; i++ ) {
arc.ArchiveObject( localSounds[ i ] );
}
}
else
{
for( int i = 0; i < num; i++ ) {
arc.ReadObject();
}
}
}
void ClientGameCommandManager::Initialize()
{
}
void ClientGameCommandManager::PlaySound( str sound_name, float *origin, int channel, float volume, float min_distance, float pitch, int argstype )
{
JMPTO( 0x30015E0C );
}
void ClientGameCommandManager::PlayLocalSound( str sound_name, qboolean loop, float volume, float time )
{
// Don't play the same sound again
StopLocalSound( sound_name );
LocalSound *localSound = new LocalSound( sound_name, loop );
localSound->Play( time, volume );
}
void ClientGameCommandManager::SetLocalSoundRate( str sound_name, float rate, float time )
{
LocalSound *localSound = GetLocalSound( sound_name );
if( !localSound ) {
return;
}
localSound->SetRate( rate, time );
}
void ClientGameCommandManager::StopLocalSound( str sound_name, float time )
{
LocalSound *localSound = GetLocalSound( sound_name );
if( localSound ) {
localSound->Stop( time );
}
}
LocalSound *ClientGameCommandManager::GetLocalSound( str sound_name )
{
for( int i = 1; i <= localSounds.NumObjects(); i++ )
{
LocalSound *localSound = localSounds.ObjectAt( i );
if( localSound->GetName() == sound_name ) {
return localSound;
}
}
return NULL;
}
void ClientSpecialEffectsManager::MakeEffect_Normal( int iEffect, Vector position, Vector normal )
{
JMPTO( 0x3003524D );
}
@@ -1,72 +0,0 @@
#ifndef __CLIENTGAMECOMMAND_H__
#define __CLIENTGAMECOMMAND_H__
#include "listener.h"
#include "scripttimer.h"
class LocalSound : public Listener {
private:
void *stream;
str name;
str path;
qboolean loop;
qboolean stopping;
int position;
int baserate;
float rate, start_rate, target_rate;
float volume, start_volume, target_volume;
ScriptTimer timer;
ScriptTimer timer_rate;
public:
CLASS_PROTOTYPE( LocalSound );
virtual void Archive( Archiver &arc );
LocalSound( str name, qboolean loop );
LocalSound();
~LocalSound();
str GetName();
void Play( float time, float volume );
void Stop( float time );
void SetRate( float rate, float time );
void Think( Event *ev );
};
#define STREAM_PLAYING 4
#define STREAM_PAUSED 16
class ClientGameCommandManager : public Listener
{
public:
static void ArchiveFunction( Archiver &arc );
static void CleanUp( void );
static void Initialize( void );
void PlaySound( str sound_name, float *origin, int channel, float volume, float min_distance, float pitch, int argstype );
void PlayLocalSound( str sound_name, qboolean loop, float volume, float time = 0.0f );
void SetLocalSoundRate( str sound_name, float rate, float time = 0.0f );
void StopLocalSound( str sound_name, float time = 0.0f );
LocalSound *GetLocalSound( str sound_name );
};
class ClientSpecialEffectsManager : public Listener
{
public:
void MakeEffect_Normal( int iEffect, Vector position, Vector normal );
};
extern ClientGameCommandManager *commandManager;
extern ClientSpecialEffectsManager *sfxManager;
#endif
@@ -1,296 +0,0 @@
/*
* ClientServerCommandManager.cpp
*
* DESCRIPTION : Client Server Command Manager. Processes server commands as event (if one).
*/
#include "clientservercommand.h"
#include "earthquake.h"
#include "cgame/cl_sound.h"
ClientServerCommandManager svcommandManager;
Event EV_ServerCommand_Earthquake
(
"eq",
EV_SERVERCMD,
"ffbbVF",
"duration magnitude no_rampup no_rampdown location radius",
"Earthquake",
EV_NORMAL
);
Event EV_ServerCommand_FadeSound
(
"fadesound2",
EV_SERVERCMD,
"ff",
"time min_vol",
"Fade the sound",
EV_NORMAL
);
Event EV_ServerCommand_RestoreSound
(
"restoresound",
EV_SERVERCMD,
"ff",
"time max_vol",
"Restore the sound",
EV_NORMAL
);
Event EV_ServerCommand_SetClientFlag
(
"cf",
EV_SERVERCMD,
"s",
"name",
"Client call back flag.",
EV_NORMAL
);
Event EV_ServerCommand_SetShader
(
"setshader",
EV_SERVERCMD,
"isb",
"ent_num shader fReset",
"Set entity shader",
EV_NORMAL
);
Event EV_ServerCommand_VisionSetBlur
(
"vsb",
EV_SERVERCMD,
"ff",
"blur_level transition_time",
"Specific server command for the naked blur vision",
EV_NORMAL
);
Event EV_ServerCommand_VisionSetNaked
(
"vsn",
EV_SERVERCMD,
"sff",
"vision transition_time phase",
"Specific server command for the naked vision",
EV_NORMAL
);
void ClientServerCommandManager::Archive( Archiver &arc )
{
}
void ClientServerCommandManager::ExecuteCommand( char *arguments[], int num_arguments )
{
const char *command = arguments[ 0 ];
const char *formatspec;
int k;
char **args = arguments + 1;
Event *ev = new Event( command, EV_NORMAL );
if( ev->eventnum == 0 )
{
delete ev;
return;
}
formatspec = ev->GetFormat();
for( int i = 0, k = 0; k < num_arguments - 1; k++ )
{
const char *argument = args[ i ];
str vec;
if( formatspec[ k ] == '\0' ) {
break;
}
if( argument == NULL || *argument == '\0' ) {
continue;
}
switch( formatspec[ k ] )
{
case 'b':
case 'B':
ev->AddInteger( atoi( argument ) );
i++;
break;
case 's':
case 'S':
ev->AddString( argument );
i++;
break;
case 'i':
case 'I':
ev->AddInteger( atoi( argument ) );
i++;
break;
case 'f':
case 'F':
ev->AddFloat( ( float )atof( argument ) );
i++;
break;
case 'v':
case 'V':
vec = args[ i ];
vec += str( " " ) + args[ i + 1 ];
vec += str( " " ) + args[ i + 2 ];
ev->AddVector( Vector( vec.c_str() ) );
i += 3;
break;
default:
ev->AddString( argument );
i++;
}
}
try
{
ProcessEvent( ev );
}
catch( ScriptException exc )
{
cgi.Printf( exc.string );
}
}
////==== EVENTS ====////
void ClientServerCommandManager::EventEarthquake( Event *ev )
{
float duration = ev->GetFloat( 1 );
float magnitude = ev->GetFloat( 2 );
qboolean no_rampup = ev->GetBoolean( 3 );
qboolean no_rampdown = ev->GetBoolean( 4 );
Vector org;
float radius;
if( ev->NumArgs() > 4 )
{
org = ev->GetVector( 5 );
if( ev->NumArgs() > 5 ) {
radius = ev->GetFloat( 6 );
}
}
Earthquake * earthquake = new Earthquake;
earthquake->SetDuration( duration );
earthquake->SetMagnitude( magnitude );
earthquake->SetNoRampup( no_rampup );
earthquake->SetNoRampdown( no_rampdown );
if( ev->NumArgs() > 4 )
{
earthquake->SetLocation( org );
if( ev->NumArgs() > 5 ) {
earthquake->SetRadius( radius );
}
}
earthquake->Enable();
}
void ClientServerCommandManager::EventFadeSound( Event *ev )
{
float time = ev->GetFloat( 1 );
float min_vol = ev->GetFloat( 2 );
CL_FadeSound2( time, min_vol );
}
void ClientServerCommandManager::EventRestoreSound( Event *ev )
{
float time = ev->GetFloat( 1 );
float max_vol = ev->GetFloat( 2 );
CL_RestoreSound( time, max_vol );
}
void ClientServerCommandManager::EventSetClientFlag( Event *ev )
{
/*str name = ev->GetString( 1 );
ClientScript *clientScript;
clientScript = new ClientScript;
clientScript->ExecuteCallback( name );
if( clientScript->ScriptFailed() ) {
delete clientScript;
}*/
}
void ClientServerCommandManager::EventSetShader( Event *ev )
{
int ent_num = ev->GetInteger( 1 );
str shadername = ev->GetString( 2 );
qboolean fReset = ev->GetBoolean( 3 );
R_SetShader( ent_num, shadername, fReset );
}
void ClientServerCommandManager::EventVisionSetBlur( Event *ev )
{
float blur_level = ev->GetFloat( 1 );
float transition_time;
if( ev->NumArgs() > 1 ) {
transition_time = ev->GetFloat( 2 );
} else {
transition_time = 0.0f;
}
R_ProcessBlur( blur_level, transition_time );
}
void ClientServerCommandManager::EventVisionSetNaked( Event *ev )
{
str vision_name = ev->GetString( 1 );
float transition_time;
float phase;
if( ev->NumArgs() > 1 ) {
transition_time = ev->GetFloat( 2 );
} else {
transition_time = 0.0f;
}
if( ev->NumArgs() > 2 ) {
phase = ev->GetFloat( 3 );
}
else {
phase = 0.0f;
}
R_ProcessVision( vision_name, transition_time, phase );
}
CLASS_DECLARATION( Listener, ClientServerCommandManager, NULL )
{
{ &EV_ServerCommand_Earthquake, &ClientServerCommandManager::EventEarthquake },
{ &EV_ServerCommand_FadeSound, &ClientServerCommandManager::EventFadeSound },
{ &EV_ServerCommand_RestoreSound, &ClientServerCommandManager::EventRestoreSound },
{ &EV_ServerCommand_SetClientFlag, &ClientServerCommandManager::EventSetClientFlag },
{ &EV_ServerCommand_SetShader, &ClientServerCommandManager::EventSetShader },
{ &EV_ServerCommand_VisionSetBlur, &ClientServerCommandManager::EventVisionSetBlur },
{ &EV_ServerCommand_VisionSetNaked, &ClientServerCommandManager::EventVisionSetNaked },
{ NULL, NULL }
};
@@ -1,26 +0,0 @@
#ifndef __CLIENTSERVERCOMMAND_H__
#define __CLIENTSERVERCOMMAND_H__
#include "listener.h"
class ClientServerCommandManager : public Listener {
public:
CLASS_PROTOTYPE( ClientServerCommandManager );
virtual void Archive( Archiver &arc );
void ExecuteCommand( char *arguments[], int num_arguments );
// Events
void EventEarthquake( Event *ev );
void EventFadeSound( Event *ev );
void EventRestoreSound( Event *ev );
void EventSetClientFlag( Event *ev );
void EventSetShader( Event *ev );
void EventVisionSetBlur( Event *ev );
void EventVisionSetNaked( Event *ev );
};
extern ClientServerCommandManager svcommandManager;
#endif // __CLIENTSERVERCOMMAND_H__
-688
View File
@@ -1,688 +0,0 @@
/*
* CPlayer.cpp
*
* DESCRIPTION : Client-side player
*/
#include "cplayer.h"
#include "earthquake.h"
#include "cgame/cg_viewmodelanim.h"
#include "archive.h"
CPlayer player;
Event EV_ReplicationInfo_GetVariable
(
"getvar",
EV_DEFAULT,
"s",
"name",
"Gets a replicated variable",
EV_RETURN
);
Event EV_Player_GetReplicationInfo
(
"replicationinfo",
EV_DEFAULT,
NULL,
NULL,
"Gets the player's replication info",
EV_GETTER
);
Event EV_Player_GetMovement
(
"getmovement",
EV_DEFAULT,
NULL,
NULL,
"Gets the player's movement state",
EV_RETURN
);
Event EV_Player_GetSpeed
(
"movespeedscale",
EV_DEFAULT,
NULL,
NULL,
"Gets the player's speed scale",
EV_GETTER
);
Event EV_Player_SetSpeed
(
"movespeedscale",
EV_DEFAULT,
"f",
"speed",
"Sets the player's speed scale until the next snapshot",
EV_SETTER
);
Event EV_Player_ViewModelAnim
(
"viewmodelanim",
EV_DEFAULT,
"si",
"anim force_restart",
"Sets the player's view model animation",
EV_NORMAL
);
void ReplicationInfo::ReplicateVariable( ScriptVariable& var )
{
replicatedvars.SetVariable( var.GetKey(), var );
}
void ReplicationInfo::EventGetVariable( Event *ev )
{
ScriptVariable *pVar = replicatedvars.GetVariable( ev->GetString( 1 ) );
if( pVar )
{
ev->AddValue( *pVar );
}
else
{
ev->AddNil();
}
}
CLASS_DECLARATION( Listener, ReplicationInfo, NULL )
{
{ &EV_ReplicationInfo_GetVariable, &ReplicationInfo::EventGetVariable },
{ NULL, NULL }
};
CPlayer::CPlayer()
{
for( int i = 0; i < MAX_DELTAANGLES; i++ )
{
_targetActive[ i ][ 0 ] = false;
_targetActive[ i ][ 1 ] = false;
_targetActive[ i ][ 2 ] = false;
VectorSet( _currentTarget[ i ], 0, 0, 0 );
VectorSet( deltaAngles[ i ], 0, 0, 0 );
VectorSet( deltaAnglesOld[ i ], 0, 0, 0 );
}
VectorSet( eyesDelta, 0, 0, 0 );
VectorSet( eyesDeltaOld, 0, 0, 0 );
debugCamera = false;
debugCameraEnd = false;
debugPoint = Vector( 0, 0, 0 );
mins = Vector( -16, -16, 0 );
maxs = Vector( 16, 16, 96 );
m_fMoveSpeedScale = 1.0f;
m_fExposure = 0.0f;
m_fExposurePrevious = 0.0f;
m_ExposureTimer.setType( TIMER_GLIDE );
renderFx = RF_INVISIBLE;
turnThinkOn();
}
void CPlayer::Archive( Archiver &arc )
{
str s;
if( this != &player )
{
player.Archive( arc );
delete this;
return;
}
Animate::Archive( arc );
for( int i = 0; i < MAX_DELTAANGLES; i++ )
{
arc.ArchiveVector( &_targetDeltaAngles[ i ] );
arc.ArchiveVector( &_targetDeltaStart[ i ] );
arc.ArchiveVector( &_targetDeltaTime[ i ] );
for( int x = 0; x < 3; x++ )
{
arc.ArchiveBoolean( &_targetActive[ i ][ x ] );
arc.ArchiveBoolean( &_godown[ i ][ x ] );
arc.ArchiveBoolean( &_glidingDown[ i ][ x ] );
arc.ArchiveBoolean( &_glideUse[ i ][ x ] );
}
arc.ArchiveVector( &_currentTarget[ i ] );
arc.ArchiveVector( &_currentDeltaTime[ i ] );
arc.ArchiveVector( &_glideRatio[ i ] );
}
arc.ArchiveBoolean( &debugCamera );
arc.ArchiveBoolean( &debugCameraEnd );
arc.ArchiveVector( &debugPoint );
arc.ArchiveVector( &debugAngles );
arc.ArchiveVector( &debugPlayerAngles );
int num_prefixes = 19;
if( !arc.Loading() )
{
for( int i = 19; i < 255; i++ )
{
if( itemName[i] != NULL && itemPrefix[i] != NULL ) {
num_prefixes++;
}
}
}
arc.ArchiveInteger( &num_prefixes );
if( arc.Saving() )
{
for( int i = 19; i < 255; i++ )
{
if( itemName[ i ] != NULL && itemPrefix[ i ] != NULL )
{
s = itemName[ i ];
arc.ArchiveString( &s );
s = itemPrefix[ i ];
arc.ArchiveString( &s );
}
}
}
else
{
for( int i = 19; i < num_prefixes; i++ )
{
arc.ArchiveString( &s );
itemName[ i ] = ( char * )malloc( s.length() + 1 );
strcpy( ( char * )itemName[ i ], s.c_str() );
arc.ArchiveString( &s );
itemPrefix[ i ] = ( char * )malloc( s.length() + 1 );
strcpy( ( char * )itemPrefix[ i ], s.c_str() );
}
}
arc.ArchiveVector( ( Vector * )&viewAngles );
arc.ArchiveVector( &avel );
arc.ArchiveVector( &oldAngles );
}
void CPlayer::Think()
{
Vector a;
Entity *ent;
cent = &cg_entities[ 0 ];
if( cg->playerFPSModel != NULL )
{
model = cg->playerFPSModel->name;
modelhandle = cg->playerFPSModelHandle;
tiki = cg->playerFPSModel;
}
else
{
model = "";
modelhandle = 0;
tiki = NULL;
}
MatrixToEulerAngles( cg->refdef.viewAxis, a );
setOrigin( cg->refdef.viewOrg );
ShakeCamera();
SmoothProcessDeltaAngles();
a[ 0 ] = abs( a[ 0 ] );
a[ 1 ] = abs( a[ 1 ] );
a[ 2 ] = abs( a[ 2 ] );
avel = a - oldAngles;
oldAngles = a;
Container< SafePtr< Entity > > entities = s_entities;
for( int i = entities.NumObjects(); i > 0; i-- )
{
ent = entities.ObjectAt( i );
if( ent && IsTouching( ent ) )
{
Event *event = new Event( EV_Touch );
event->AddEntity( this );
ent->ProcessEvent( event );
}
}
/*if( m_ExposureTrigger != NULL && !IsTouching( m_ExposureTrigger ) )
{
TriggerExposure *trigger = ( TriggerExposure * )m_ExposureTrigger.Pointer();
m_fExposureStart = m_fExposure;
m_fExposureTarget = 0.0f;
m_ExposureTimer.SetTime( trigger->m_fExposureTime );
m_ExposureTimer.Enable();
m_ExposureTrigger = NULL;
}*/
m_fExposure = m_ExposureTimer.LerpValue( m_fExposureStart, m_fExposureTarget );
Animate::Think();
}
void CPlayer::ShakeCamera()
{
// Shake the current player's camera
float earthquakeMagnitude = 0.0f;
Earthquake *eq;
float magnitude;
for( int i = earthquakes.NumObjects(); i > 0; i-- )
{
eq = earthquakes.ObjectAt( i );
if( !eq->isActive() ) {
continue;
}
magnitude = eq->getMagnitude();
if( eq->hasLocation() )
{
Vector location = eq->getLocation();
float radius = eq->getRadius();
if( inRadius( location, radius ) )
{
Vector org = origin;
Vector dir = org - location;
float dist = dir.length();
magnitude = magnitude - ( magnitude * ( dist / radius ) );
}
else
{
magnitude = 0.0f;
}
}
earthquakeMagnitude += magnitude;
}
if( earthquakeMagnitude <= 0.0f )
{
VectorSet( deltaAngles[ ANGLES_EQ ], 0, 0, 0 );
return;
}
magnitude = earthquakeMagnitude / 2.0f;
if( !_targetActive[ ANGLES_EQ ][ PITCH ] )
{
float angle;
if( !_godown[ ANGLES_EQ ][ PITCH ] )
{
angle = 1.85f * magnitude;
_godown[ ANGLES_EQ ][ PITCH ] = true;
}
else
{
angle = -1.85f * magnitude;
_godown[ ANGLES_EQ ][ PITCH ] = false;
}
SmoothSetDeltaAngle( ANGLES_EQ, PITCH, 0.105f, angle );
}
if( !_targetActive[ ANGLES_EQ ][ YAW ] )
{
float angle;
if( !_godown[ ANGLES_EQ ][ YAW ] )
{
angle = 1.75f * magnitude;
_godown[ ANGLES_EQ ][ YAW ] = true;
}
else
{
angle = -1.75f * magnitude;
_godown[ ANGLES_EQ ][ YAW ] = false;
}
SmoothSetDeltaAngle( ANGLES_EQ, YAW, 0.060f, angle );
}
if( !_targetActive[ ANGLES_EQ ][ ROLL ] )
{
float angle;
if( !_godown[ ANGLES_EQ ][ ROLL ] )
{
angle = 1.35f * magnitude;
_godown[ ANGLES_EQ ][ ROLL ] = true;
}
else
{
angle = -1.35f * magnitude;
_godown[ ANGLES_EQ ][ ROLL ] = false;
}
SmoothSetDeltaAngle( ANGLES_EQ, ROLL, 0.082f, angle );
}
}
void CPlayer::SmoothSetDeltaAngles( int port, float time, vec3_t newDeltaAngles, qboolean bMoveVM )
{
SmoothSetDeltaAngle( port, 0, time, newDeltaAngles[ 0 ] );
SmoothSetDeltaAngle( port, 1, time, newDeltaAngles[ 1 ] );
SmoothSetDeltaAngle( port, 2, time, newDeltaAngles[ 2 ] );
}
void CPlayer::SmoothSetDeltaAngle( int port, int index, float time, float angle )
{
if( index > 2 ) {
return;
}
float realtime = time * 1000.0f + 0.5f;
_currentDeltaTime[ port ][ index ] = 0.0f;
deltaAngles[ port ][ index ] = _currentTarget[ port ][ index ];
_glideRatio[ port ][ index ] = 0.0f;
_glidingDown[ port ][ index ] = false;
_glideTime[ port ][ index ] = 0.0f;
_glideUse[ port ][ index ] = ( ( realtime / 2 ) > cg->frametime ) ? true : false;
_targetDeltaAngles[ port ][ index ] = angle;
_targetDeltaStart[ port ][ index ] = _currentTarget[ port ][ index ];
_targetDeltaTime[ port ][ index ] = realtime;
_targetActive[ port ][ index ] = true;
}
void CPlayer::SmoothProcessDeltaAngle( int port, int index )
{
if( index > 2 || port >= MAX_DELTAANGLES ) {
return;
}
// Process each angle
if( !_targetActive[ port ][ index ] ) {
return;
}
_glideTime[ port ][ index ] += cg->frametime;
// Glide the angle by time
if( _glideUse[ port ][ index ] )
{
if( _glidingDown[ port ][ index ] )
{
//_glideRatio[ port ][ index ] -= 2.0f/( _targetDeltaTime[ port ][ index ]/2 ) * cg->frametime;
_glideRatio[ port ][ index ] = 2.0f - 2.0f * _glideTime[ port ][ index ] / ( _targetDeltaTime[ port ][ index ] / 2.0f );
if( _glideRatio[ port ][ index ] < 0.0f )
{
_glideRatio[ port ][ index ] = 0.0f;
_glidingDown[ port ][ index ] = false;
_glideTime[ port ][ index ] = 0.0f;
}
}
else
{
//_glideRatio[ port ][ index ] += 2.0f/( _targetDeltaTime[ port ][ index ]/2 ) * cg->frametime;
_glideRatio[ port ][ index ] = 2.0f * _glideTime[ port ][ index ] / ( _targetDeltaTime[ port ][ index ] / 2.0f );
if( _glideRatio[ port ][ index ] > 2.0f )
{
_glideRatio[ port ][ index ] = 2.0f;
_glidingDown[ port ][ index ] = true;
_glideTime[ port ][ index ] = 0.0f;
}
}
_currentDeltaTime[ port ][ index ] += cg->frametime * _glideRatio[ port ][ index ];
} else {
_currentDeltaTime[ port ][ index ] += cg->frametime;
}
float ratio = _currentDeltaTime[ port ][ index ] / _targetDeltaTime[ port ][ index ];
if( ratio >= 1.0f )
{
deltaAngles[ port ][ index ] = _targetDeltaAngles[ port ][ index ];
_currentTarget[ port ][ index ] = _targetDeltaAngles[ port ][ index ];
_targetActive[ port ][ index ] = false;
return;
}
deltaAngles[ port ][ index ] = _targetDeltaStart[ port ][ index ] + ( _targetDeltaAngles[ port ][ index ] - _targetDeltaStart[ port ][ index ] ) * ratio;
_currentTarget[ port ][ index ] = deltaAngles[ port ][ index ];
}
void CPlayer::SmoothProcessDeltaAngles()
{
for( int i = 0; i < MAX_DELTAANGLES; i++ )
{
SmoothProcessDeltaAngle( i, 0 );
SmoothProcessDeltaAngle( i, 1 );
SmoothProcessDeltaAngle( i, 2 );
}
}
void CPlayer::DebugCamera()
{
if( !cg_debugview->integer )
{
//debugCamera = false;
if( !debugCameraEnd )
{
// Restore the player's view angles
VectorCopy( debugPlayerAngles, viewAngles );
debugCameraEnd = true;
}
return;
}
// Initialize debug point
if( !debugCamera )
{
debugCamera = true;
debugAngles = cg->refdefViewAngles;
debugPoint = cg->refdef.viewOrg;
debugPoint.z += cg->predictedPlayerState.viewheight;
}
if( debugCameraEnd )
{
// Save the player's view angles
debugPlayerAngles = viewAngles;
// Restore the debug camera's view angles
VectorCopy( debugAngles, viewAngles );
debugCameraEnd = false;
}
// Save the camera's view angles
debugAngles = viewAngles;
cg->predictedPlayerState.camera_flags |= 8;
kbutton_t *forward = ( kbutton_t * )0x12F6FE0;
kbutton_t *backward = ( kbutton_t * )0x12F70C0;
kbutton_t *moveleft = ( kbutton_t * )0x12F7040;
kbutton_t *moveright = ( kbutton_t * )0x12F70A0;
kbutton_t *movedown = ( kbutton_t * )0x012F6FC0;
kbutton_t *moveup = ( kbutton_t* )0x012F6FA0;
Vector newAngles = cg->refdefViewAngles;
//newAngles[ 0 ] = 0.f;
if( forward->active )
{
Vector fwdvec;
AngleVectors( newAngles, fwdvec, NULL, NULL );
debugPoint = debugPoint + fwdvec * ( ( float )cg->frametime * 2 );
}
if( backward->active )
{
Vector backvec;
AngleVectors( newAngles, backvec, NULL, NULL );
debugPoint = debugPoint - backvec * ( ( float )cg->frametime * 2 );
}
if( moveleft->active )
{
Vector leftvec;
AngleVectors( newAngles, NULL, leftvec, NULL );
debugPoint = debugPoint + leftvec * ( ( float )cg->frametime * 2 );
}
if( moveright->active )
{
Vector rightvec;
AngleVectors( newAngles, NULL, rightvec, NULL );
debugPoint = debugPoint - rightvec * ( ( float )cg->frametime * 2 );
}
if( moveup->active )
{
Vector upvec;
newAngles.x = 0.f;
AngleVectors( newAngles, NULL, NULL, upvec );
debugPoint = debugPoint + upvec * ( ( float )cg->frametime );
}
if( movedown->active )
{
Vector downvec;
newAngles.x = 0.f;
AngleVectors( newAngles, NULL, NULL, downvec );
debugPoint = debugPoint - downvec * ( ( float )cg->frametime );
}
cg->refdef.viewOrg[ 0 ] = debugPoint[ 0 ];
cg->refdef.viewOrg[ 1 ] = debugPoint[ 1 ];
cg->refdef.viewOrg[ 2 ] = debugPoint[ 2 ];
VectorCopy( cg->refdef.viewOrg, cg->currentViewPos );
VectorCopy( cg->refdef.viewOrg, cg->playerHeadPos );
VectorCopy( cg->refdef.viewOrg, cg->cameraOrigin );
VectorCopy( cg->refdef.viewOrg, cg->soundOrg );
VectorCopy( cg->refdef.viewOrg, cg->predictedPlayerState.camera_origin );
//VectorCopy( cg->refdef.viewOrg, cg->predictedPlayerState.origin );
//cg->predictedPlayerState.origin[ 0 ] -= cg->predictedPlayerState.viewHeight;
}
// Script
void CPlayer::EventGetMovement( Event *ev )
{
kbutton_t *forward = ( kbutton_t * )0x12F6FE0;
kbutton_t *movedown = ( kbutton_t* )0x012F6FC0;
kbutton_t *moveup = ( kbutton_t* )0x012F6FA0;
if( forward->active && !moveup->active && !movedown->active )
{
ev->AddString( "forward" );
}
else if( movedown->active )
{
ev->AddString( "crouch" );
}
else if( moveup->active )
{
ev->AddString( "jump" );
}
else
{
ev->AddString( "idle" );
}
}
void CPlayer::EventGetReplicationInfo( Event *ev )
{
ev->AddListener( &replication );
}
void CPlayer::EventGetSpeed( Event *ev )
{
ev->AddFloat( m_fMoveSpeedScale );
}
void CPlayer::EventSetSpeed( Event *ev )
{
m_fMoveSpeedScale = ev->GetFloat( 1 );
}
void CPlayer::EventViewModelAnim( Event *ev )
{
if( cg->snap != NULL )
{
cg->snap->ps.iViewModelAnim = VMA_CUSTOMANIMATION;
}
cgi.anim->lastVMAnim = VMA_CUSTOMANIMATION;
cgi.anim->lastVMAnimChanged = ( cg->snap->ps.iViewModelAnimChanged + 1 ) & 3;
CG_ViewModelAnim( ( char * )ev->GetString( 1 ).c_str(), false );
}
CLASS_DECLARATION( CAnimate, CPlayer, NULL )
{
{ &EV_Player_GetMovement, &CPlayer::EventGetMovement },
{ &EV_Player_GetReplicationInfo, &CPlayer::EventGetReplicationInfo },
{ &EV_Player_GetSpeed, &CPlayer::EventGetSpeed },
{ &EV_Player_SetSpeed, &CPlayer::EventSetSpeed },
{ &EV_Player_ViewModelAnim, &CPlayer::EventViewModelAnim },
{ NULL, NULL }
};
-97
View File
@@ -1,97 +0,0 @@
#ifndef __CPLAYER_H__
#define __CPLAYER_H__
#include "canimate.h"
#include "scripttimer.h"
#include "scriptvariable.h"
// EQ prefix = earthquake
#define ANGLES_EQ 0
#define MAX_DELTAANGLES 4
class ReplicationInfo : public Listener
{
private:
ScriptVariableList replicatedvars;
public:
CLASS_PROTOTYPE( ReplicationInfo );
void ReplicateVariable( ScriptVariable& variable );
void EventGetVariable( Event *ev );
};
class CPlayer : public Animate
{
private:
Vector _targetDeltaAngles[ MAX_DELTAANGLES ];
Vector _targetDeltaStart[ MAX_DELTAANGLES ];
Vector _targetDeltaTime[ MAX_DELTAANGLES ];
qboolean _targetActive[ MAX_DELTAANGLES ][ 3 ];
qboolean _godown[ MAX_DELTAANGLES ][ 3 ];
Vector _currentTarget[ MAX_DELTAANGLES ];
Vector _currentDeltaTime[ MAX_DELTAANGLES ];
Vector _glideRatio[ MAX_DELTAANGLES ];
Vector _glideTime[ MAX_DELTAANGLES ];
qboolean _glidingDown[ MAX_DELTAANGLES ][ 3 ];
qboolean _glideUse[ MAX_DELTAANGLES ][ 3 ];
qboolean debugCamera;
qboolean debugCameraEnd;
Vector debugPoint;
Vector debugAngles;
Vector debugPlayerAngles;
public:
float deltaAnglesOld[MAX_DELTAANGLES][3];
float deltaAngles[MAX_DELTAANGLES][3];
Vector eyesDelta;
Vector eyesDeltaOld;
Vector vAngles;
Vector oldAngles;
Vector avel;
ReplicationInfo replication;
float m_fMoveSpeedScale;
SafePtr< Entity > m_ExposureTrigger;
float m_fExposure;
float m_fExposurePrevious;
float m_fExposureStart;
float m_fExposureTarget;
ScriptTimer m_ExposureTimer;
playerState_t *ps;
private:
void SmoothProcessDeltaAngles( void );
void SmoothProcessDeltaAngle( int port, int index );
public:
CLASS_PROTOTYPE( CPlayer );
virtual void Archive( Archiver &arc );
CPlayer();
virtual void Think( void );
void DebugCamera( void );
void ShakeCamera( void );
void SmoothSetDeltaAngles( int port, float time, vec3_t newDeltaAngles, qboolean bMoveVM = false );
void SmoothSetDeltaAngle( int port, int index, float time, float angle );
void EventGetMovement( Event *ev );
void EventGetReplicationInfo( Event *ev );
void EventGetSpeed( Event *ev );
void EventSetSpeed( Event *ev );
void EventViewModelAnim( Event *ev );
};
extern CPlayer player;
#endif
-232
View File
@@ -1,232 +0,0 @@
/*
* Earthquake.cpp
*
* DESCRIPTION : Client-side realistic earthquake and network optimizer
*/
#include "earthquake.h"
#include "archive.h"
Event EV_Earthquake_Think
(
"eq_think",
EV_CODEONLY,
NULL,
NULL,
"Internal event",
EV_NORMAL
);
Container< Earthquake * > earthquakes;
Earthquake::Earthquake()
{
_duration = 1.0f;
_magnitude = 0.7f;
_no_rampup = false;
_no_rampdown = false;
_location = Vector( 0, 0, 0 );
_radius = 1000.0f;
active = false;
earthquakes.AddObject( this );
}
Earthquake::Earthquake( float duration, float magnitude, qboolean no_rampup, qboolean no_rampdown, Vector location, float radius )
{
SetDuration( duration );
SetMagnitude( magnitude );
SetNoRampup( no_rampup );
SetNoRampdown( no_rampdown );
SetLocation( location );
SetRadius( radius );
active = false;
earthquakes.AddObject( this );
}
Earthquake::~Earthquake()
{
Disable();
earthquakes.RemoveObject( this );
}
void Earthquake::Archive( Archiver &arc )
{
SimpleEntity::Archive( arc );
arc.ArchiveFloat( &_duration );
arc.ArchiveFloat( &_magnitude );
arc.ArchiveBoolean( &_no_rampup );
arc.ArchiveBoolean( &_no_rampdown );
arc.ArchiveVector( &_location );
arc.ArchiveFloat( &_radius );
arc.ArchiveFloat( &_currentMagnitude );
arc.ArchiveFloat( &_currentTime );
arc.ArchiveBoolean( &active );
if( arc.Loading() ) {
_startTime = cg->time - _currentTime;
}
}
float Earthquake::getMagnitude()
{
return _currentMagnitude;
}
Vector Earthquake::getLocation()
{
return _location;
}
float Earthquake::getRadius()
{
return _radius;
}
qboolean Earthquake::hasLocation()
{
return _location != Vector( 0, 0, 0 );
}
void Earthquake::SetDuration( float duration )
{
_duration = duration * 1000.0f;
}
void Earthquake::SetMagnitude( float magnitude )
{
_magnitude = magnitude;
}
void Earthquake::SetNoRampup( qboolean no_rampup )
{
_no_rampup = no_rampup;
}
void Earthquake::SetNoRampdown( qboolean no_rampdown )
{
_no_rampdown = no_rampdown;
}
void Earthquake::SetLocation( Vector origin )
{
_location = origin;
}
void Earthquake::SetRadius( float radius )
{
_radius = radius;
}
void Earthquake::Enable( void )
{
if ( _duration > 0.0f )
{
_startTime = ( float )cg->time;
_currentMagnitude = _magnitude;
_currentTime = 0.0f;
active = true;
ProcessScriptEvent( EV_Earthquake_Think );
}
}
void Earthquake::Disable( void )
{
active = false;
_startTime = 0.0f;
_currentMagnitude = 0.0f;
_currentTime = 0.0f;
CancelEventsOfType( EV_Earthquake_Think );
}
qboolean Earthquake::isActive( void )
{
return active;
}
void Earthquake::Think( Event *ev )
{
float timeDelta;
if( !active )
{
CancelEventsOfType( EV_Earthquake_Think );
return;
}
// Disable the earthquake if the time reached the maximum duration
if( _currentTime >= _duration )
{
delete this;
return;
}
_currentTime += cg->frametime;
timeDelta = cgi.Milliseconds() - _startTime;
// we are in the first half of the earthquake
if ( timeDelta < ( _duration * 0.5f ) )
{
if ( !_no_rampup )
{
float rampUpTime;
rampUpTime = _startTime + ( _duration * 0.33f );
if ( cg->time < rampUpTime )
{
float scale;
scale = ( timeDelta ) / ( _duration * 0.33f );
_currentMagnitude = _magnitude * scale;
} else {
_currentMagnitude = _magnitude;
}
}
}
// we are in the second half of the earthquake
else
{
if ( !_no_rampdown )
{
float rampDownTime;
rampDownTime = _startTime + ( _duration * 0.66f );
if ( cg->time > rampDownTime )
{
float scale;
scale = 1.0f - ( ( cg->time - rampDownTime ) / ( _duration * 0.33f ) );
_currentMagnitude = _magnitude * scale;
} else {
_currentMagnitude = _magnitude;
}
}
}
CancelEventsOfType( EV_Earthquake_Think );
PostEvent( EV_Earthquake_Think, level.frametime );
}
CLASS_DECLARATION( SimpleEntity, Earthquake, NULL )
{
{ &EV_Earthquake_Think, &Earthquake::Think },
{ NULL, NULL },
};
-53
View File
@@ -1,53 +0,0 @@
#ifndef __EARTHQUAKE_H__
#define __EARTHQUAKE_H__
#include "simpleentity.h"
class Earthquake : public SimpleEntity
{
private:
float _duration;
float _magnitude;
qboolean _no_rampup;
qboolean _no_rampdown;
Vector _location;
float _radius;
float _currentMagnitude;
float _currentTime;
float _startTime;
qboolean active;
public:
CLASS_PROTOTYPE( Earthquake );
virtual void Archive( Archiver &arc );
Earthquake();
Earthquake( float duration, float magnitude, qboolean no_rampup, qboolean no_rampdown, Vector location = Vector( 0, 0, 0 ), float radius = 1.0f );
virtual ~Earthquake();
void Enable( void );
void Disable( void );
qboolean isActive( void );
float getMagnitude( void );
Vector getLocation( void );
float getRadius( void );
qboolean hasLocation( void );
void SetDuration( float duration );
void SetMagnitude( float magnitude );
void SetNoRampup( qboolean no_rampup );
void SetNoRampdown( qboolean no_rampdown );
void SetLocation( Vector origin );
void SetRadius( float radius );
void Think( Event *ev );
};
extern Container< Earthquake * > earthquakes;
#endif
-64
View File
@@ -1,64 +0,0 @@
/*
* Level.cpp
*
* DESCRIPTION : Global level info
*/
#include "level.h"
Event EV_Level_testf
(
"testf",
EV_DEFAULT,
"i",
"test_int",
"test",
EV_SETTER
);
Level level;
Level::Level()
{
prespawned = false;
spawned = false;
}
Level::~Level()
{
}
void Level::setTime( int levelTime )
{
svsTime = levelTime;
inttime = levelTime - svsStartTime;
svsFloatTime = levelTime / 1000.0f;
time = inttime / 1000.0f;
}
void Level::setFrametime( int frametime )
{
intframetime = frametime;
this->frametime = frametime / 1000.0f;
}
void Level::Archive( Archiver &arc )
{
Listener::Archive( arc );
}
void Level::TestEvent( Event *ev )
{
int integer = ev->GetInteger( 1 );
cgi.Printf( "this = %p\n", this );
cgi.Printf( "SCRIPT: integer = %d\n", integer );
}
CLASS_DECLARATION( Listener, Level, NULL )
{
{ &EV_Level_testf, &Level::TestEvent },
{ NULL, NULL }
};
-58
View File
@@ -1,58 +0,0 @@
#ifndef __LEVEL_H__
#define __LEVEL_H__
#include "listener.h"
class SimpleArchivedEntity;
class Level : public Listener
{
public:
bool m_LoopDrop;
bool m_LoopProtection;
str m_mapscript;
str current_map;
// Level time
int framenum;
int inttime;
int intframetime;
float time;
float frametime;
int spawnflags;
// Server time
int svsTime;
float svsFloatTime;
int svsStartTime;
int svsEndTime;
bool m_bScriptSpawn;
bool m_bRejectSpawn;
Container< SimpleArchivedEntity * > m_SimpleArchivedEntities;
qboolean prespawned;
qboolean spawned;
public:
CLASS_PROTOTYPE( Level );
void setTime( int _svsTime_ );
void setFrametime( int frameTime );
virtual void Archive( Archiver &arc );
Level();
~Level();
void TestEvent( Event *ev );
};
extern Level level;
#endif // __LEVEL_H__
-319
View File
@@ -1,319 +0,0 @@
/*
* ScriptSlave.cpp
*
* DESCRIPTION : Client-side script slave
*/
#include "scriptslave.h"
Event EV_ScriptSlave_GetSpeed
(
"speed",
EV_DEFAULT,
NULL,
NULL,
"Gets the speed.",
EV_GETTER
);
Event EV_ScriptSlave_GetTime
(
"time",
EV_DEFAULT,
NULL,
NULL,
"Gets the travel time.",
EV_GETTER
);
Event EV_ScriptSlave_MoveTo
(
"moveto",
EV_DEFAULT,
"s",
"vector_or_entity",
"Move to the specified vector or entity.",
EV_NORMAL
);
Event EV_ScriptSlave_Move
(
"move",
EV_DEFAULT,
NULL,
NULL,
"Move the script slave.",
EV_NORMAL
);
Event EV_ScriptSlave_SetSpeed
(
"speed",
EV_DEFAULT,
"f",
"speed",
"Sets the speed.",
EV_SETTER
);
Event EV_ScriptSlave_SetTime
(
"time",
EV_DEFAULT,
"f",
"travel_time",
"Sets the travel time.",
EV_SETTER
);
Event EV_ScriptSlave_StopMove
(
"stopmove",
EV_DEFAULT,
NULL,
NULL,
"Make the script slave stop moving.",
EV_NORMAL
);
Event EV_ScriptSlave_WaitMove
(
"waitmove",
EV_DEFAULT,
NULL,
NULL,
"Move the script slave and wait until finished.",
EV_NORMAL
);
void ScriptSlave::Archive( Archiver &arc )
{
}
ScriptSlave::ScriptSlave()
{
moveflags = 0;
slavetype = MOVE_UNSET;
target.origin = NULL;
movespeed = 200.0f;
movetime = 1.0f;
moving = false;
currentTime = 0.f;
turnThinkOn();
}
ScriptSlave::~ScriptSlave()
{
ClearMove();
}
void ScriptSlave::Think()
{
if( moving )
{
float length;
Vector targetOrigin;
// Calculate the length
if( slavetype == MOVE_ENTITY )
{
Entity *ent = ( Entity* )target.entity->Pointer();
if( ent ) {
targetOrigin = ent->origin;
} else {
targetOrigin = vec_zero;
}
}
else
{
targetOrigin = target.origin;
}
if( movespeed > 0.0f && !movetimedone )
{
length = Vector::Distance( origin, targetOrigin );
movetime = ( length / movespeed ) * 1000.0f;
movetimedone = true;
}
float ratio = currentTime / movetime;
currentTime += cg->frametime;
if( ratio >= 1.0f )
{
ratio = 1.0f;
ClearMove();
}
setOrigin( startOrigin + ( targetOrigin - startOrigin ) * ratio );
}
Animate::Think();
}
void ScriptSlave::ClearMove()
{
if( slavetype == MOVE_ENTITY )
{
if( target.entity ) {
delete target.entity;
}
}
else if( slavetype == MOVE_ORIGIN )
{
if( target.origin ) {
delete ( Vector * ) target.origin;
}
}
moving = false;
currentTime = 0.f;
slavetype = MOVE_UNSET;
}
float ScriptSlave::GetSpeed()
{
return movespeed;
}
float ScriptSlave::GetTime()
{
return movetime;
}
void ScriptSlave::MoveTo( Entity *entity )
{
ClearMove();
setSlaveType( MOVE_ENTITY );
target.entity = new SafePtr < Entity > ;
target.entity->InitSafePtr( entity );
}
void ScriptSlave::MoveTo( Vector origin )
{
ClearMove();
setSlaveType( MOVE_ORIGIN );
target.origin = ( float * ) new Vector( origin );
}
void ScriptSlave::Move()
{
if( slavetype == MOVE_UNSET ) {
ScriptError( "No target set for the ScriptSlave !\n" );
}
moving = true;
movetimedone = false;
startOrigin = origin;
}
void ScriptSlave::SetSpeed( float speed )
{
if( speed >= 0.f )
{
movespeed = speed;
movetime = 0.0f;
}
}
void ScriptSlave::SetTime( float time )
{
if( time >= 0.f )
{
movespeed = 0.0f;
movetime = time * 1000.0f;
}
}
void ScriptSlave::StopMove()
{
ClearMove();
}
s_movetype ScriptSlave::getSlaveType()
{
return slavetype;
}
void ScriptSlave::setSlaveType( s_movetype type )
{
slavetype = type;
}
//=== SCRIPT ===\\
void ScriptSlave::EventGetSpeed( Event *ev )
{
ev->AddFloat( GetSpeed() );
}
void ScriptSlave::EventGetTime( Event *ev )
{
ev->AddFloat( GetTime() );
}
void ScriptSlave::EventMove( Event *ev )
{
Move();
}
void ScriptSlave::EventMoveTo( Event *ev )
{
if( ev->IsStringAt( 1 ) || ev->IsVectorAt( 1 ) )
{
Vector pos = ev->GetVector( 1 );
MoveTo( pos );
}
else if( ev->IsEntityAt( 1 ) )
{
Entity *ent = ev->GetEntity( 1 );
MoveTo( ent );
}
}
void ScriptSlave::EventSetSpeed( Event *ev )
{
SetSpeed( ev->GetFloat( 1 ) );
}
void ScriptSlave::EventSetTime( Event *ev )
{
SetTime( ev->GetFloat( 1 ) );
}
void ScriptSlave::EventStopMove( Event *ev )
{
StopMove();
}
void ScriptSlave::EventWaitMove( Event *ev )
{
Move();
}
CLASS_DECLARATION( CAnimate, ScriptSlave, "client_script_object" )
{
{ &EV_ScriptSlave_GetSpeed, &ScriptSlave::EventGetSpeed },
{ &EV_ScriptSlave_GetTime, &ScriptSlave::EventGetTime },
{ &EV_ScriptSlave_Move, &ScriptSlave::EventMove },
{ &EV_ScriptSlave_MoveTo, &ScriptSlave::EventMoveTo },
{ &EV_ScriptSlave_SetSpeed, &ScriptSlave::EventSetSpeed },
{ &EV_ScriptSlave_SetTime, &ScriptSlave::EventSetTime },
{ &EV_ScriptSlave_StopMove, &ScriptSlave::EventStopMove },
{ &EV_ScriptSlave_WaitMove, &ScriptSlave::EventWaitMove },
{ NULL, NULL }
};
-71
View File
@@ -1,71 +0,0 @@
#ifndef __SCRIPTSLAVE_H__
#define __SCRIPTSLAVE_H__
#include "canimate.h"
#define MF_GLIDE (1<<0) // The script slave will glide when moving
#define MF_TIMEDMOVE (1<<1) // The script slave will move within the specified time
typedef enum
{
MOVE_UNSET,
MOVE_ENTITY,
MOVE_ORIGIN
} s_movetype;
class ScriptSlave : public Animate
{
private:
int moveflags;
s_movetype slavetype;
float movespeed;
float movetime;
qboolean movetimedone;
float currentTime;
qboolean moving;
union {
SafePtr<Entity> *entity;
float *origin;
} target;
Vector startOrigin;
public:
CLASS_PROTOTYPE( ScriptSlave );
virtual void Archive( Archiver &arc );
ScriptSlave();
~ScriptSlave();
virtual void Think();
void ClearMove();
float GetSpeed();
float GetTime();
void MoveTo( Entity *entity );
void MoveTo( Vector origin );
void Move();
void SetSpeed( float speed );
void SetTime( float time );
void StopMove();
s_movetype getSlaveType();
void setSlaveType( s_movetype type );
void EventGetSpeed( Event *ev );
void EventGetTime( Event *ev );
void EventMove( Event *ev );
void EventMoveTo( Event *ev );
void EventSetSpeed( Event *ev );
void EventSetTime( Event *ev );
void EventStopMove( Event *ev );
void EventWaitMove( Event *ev );
};
#endif /* __SCRIPTSLAVE_H__ */
-147
View File
@@ -1,147 +0,0 @@
#ifndef __VISION_H__
#define __VISION_H__
#include "class.h"
class ScriptTimer;
class VisionClass : public Class
{
private:
str name;
str defaultval;
protected:
str string;
ScriptTimer *m_timer;
float value;
float value_start;
float value_target;
public:
qboolean fProcessed;
protected:
void VisionInit( const char *name, const char *value, ScriptTimer *globalTimer );
public:
CLASS_PROTOTYPE( VisionClass );
virtual void Archive( Archiver &arc );
static VisionClass *Get( str name );
static void GlobalArchive( Archiver &arc );
VisionClass();
VisionClass( const char *name, const char *value, ScriptTimer *globalTimer );
virtual void Think();
str GetName();
ScriptTimer *GetTimer();
virtual str GetType();
str defaultValue();
float floatValue();
str stringValue();
virtual qboolean isBasic();
virtual qboolean isEnabled();
virtual qboolean isNewEnabled();
void setFloatValue( float value );
virtual void setValue( str value );
};
class VisionActivator : public VisionClass
{
private:
str vistype;
public:
CLASS_PROTOTYPE( VisionActivator );
virtual void Archive( Archiver &arc );
VisionActivator( const char *name, const char *value, const char *type = "vision", ScriptTimer *globalTimer = NULL );
VisionActivator();
virtual str GetType();
virtual qboolean isBasic();
virtual qboolean isEnabled();
virtual qboolean isNewEnabled();
virtual void setValue( str value );
};
class VisionVariable : public VisionClass
{
private:
VisionActivator *activator;
Vector vector;
// target values
Vector vector_start;
Vector vector_target;
public:
CLASS_PROTOTYPE( VisionVariable );
virtual void Archive( Archiver &arc );
VisionVariable( const char *name, const char *value, VisionActivator *activator );
VisionVariable();
virtual void Think();
VisionActivator *GetActivator();
ScriptTimer *GetTimer();
virtual str GetType();
virtual qboolean isBasic();
virtual qboolean isEnabled();
virtual qboolean isNewEnabled();
Vector vectorValue();
virtual void setValue( str value );
};
extern VisionActivator r_anaglyphTweakEnable;
extern VisionActivator r_distortionEnable;
extern VisionActivator r_filmEnable;
extern VisionActivator r_glow;
extern VisionVariable r_glowRadius0;
extern VisionVariable r_glowRadius1;
extern VisionVariable r_glowBloomCutoff;
extern VisionVariable r_glowBloomDesaturation;
extern VisionVariable r_glowBloomIntensity0;
extern VisionVariable r_glowBloomIntensity1;
extern VisionVariable r_glowBloomStreakX;
extern VisionVariable r_glowBloomStreakY;
extern VisionVariable r_filmContrast;
extern VisionVariable r_filmBleach;
extern VisionVariable r_filmBrightness;
extern VisionVariable r_filmHue;
extern VisionVariable r_filmMidStart;
extern VisionVariable r_filmMidEnd;
extern VisionVariable r_filmDarkTint;
extern VisionVariable r_filmMidTint;
extern VisionVariable r_filmLightTint;
extern VisionVariable r_filmSaturation;
extern VisionVariable r_anaglyphAngleMult;
extern VisionVariable r_anaglyphOffsetMult;
extern VisionVariable r_distortionRadius;
extern VisionVariable r_distortionScale;
#endif
+3 -1
View File
@@ -37,10 +37,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "characterstate.h"
#include "weaputils.h"
#include "player.h"
#include <parm.h>
#include "bg_local.h"
#include "weapturret.h"
#include "sentient.h"
#include <parm.h>
#include <tiki.h>
#include <cmath>
Vector MINS(-15.0,-15.0,0.0);
+2 -1
View File
@@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "animate.h"
#include "../game/player.h"
#include "../qcommon/qfiles.h"
#include <tiki.h>
// Leg Animation events
Event EV_SetAnim
@@ -61,7 +62,7 @@ Event EV_Animate_IsLoopingAnim
EV_RETURN
);
MEM_BlockAlloc< AnimationEvent, MEM_BLOCKSIZE > AnimationEvent_allocator;
MEM_BlockAlloc<AnimationEvent> AnimationEvent_allocator;
void *AnimationEvent::operator new( size_t size )
{
+1 -1
View File
@@ -145,7 +145,7 @@ public:
void StopAnimating( Event *ev );
};
extern MEM_BlockAlloc< AnimationEvent, MEM_BLOCKSIZE > AnimationEvent_allocator;
extern MEM_BlockAlloc<AnimationEvent> AnimationEvent_allocator;
inline int Animate::CurrentAnim( int slot )
{
+10 -14
View File
@@ -201,10 +201,10 @@ qboolean FileRead::Open
}
else
{
size_t new_len;
uint32_t new_len;
size_t iCSVGLength;
Read( &new_len, sizeof( unsigned int ) );
Read( &new_len, sizeof(uint32_t) );
tempbuf = ( byte * )glbs.Malloc( new_len );
if( g_lz77.Decompress( pos, length - 8, tempbuf, &iCSVGLength ) || iCSVGLength != new_len )
@@ -538,13 +538,13 @@ void
}
}
inline size_t Archiver::ReadSize
inline fileSize_t Archiver::ReadSize
(
void
)
{
size_t s;
fileSize_t s;
s = 0;
if( !fileerror )
@@ -558,11 +558,11 @@ void
inline void Archiver::CheckSize
(
int type,
size_t size
fileSize_t size
)
{
size_t s;
fileSize_t s;
if( !fileerror )
{
@@ -575,11 +575,7 @@ size_t size
}
}
inline void Archiver::WriteSize
(
size_t size
)
inline void Archiver::WriteSize(fileSize_t size)
{
glbs.FS_Write( &size, sizeof( size ), file );
}
@@ -964,7 +960,7 @@ str * string
{
if( archivemode == ARCHIVE_READ )
{
size_t s;
fileSize_t s;
char *data;
#ifndef NDEBUG
@@ -1003,7 +999,7 @@ str * string
#ifdef ARCHIVE_USE_TYPES
WriteType( ARC_String );
#endif
WriteSize( string->length() );
WriteSize( (fileSize_t)string->length() );
glbs.FS_Write( ( void * )string->c_str(), string->length(), file );
}
}
@@ -1125,7 +1121,7 @@ void Archiver::ArchiveObject
{
str classname;
int index;
size_t size;
fileSize_t size;
qboolean isent;
if( archivemode == ARCHIVE_READ )
+5 -3
View File
@@ -51,6 +51,8 @@ typedef struct
int type;
} pointer_fixup_t;
using fileSize_t = uint32_t;
class FileRead : public Class
{
protected:
@@ -93,13 +95,13 @@ protected:
void CheckRead( void );
void CheckType( int type );
int ReadType( void );
size_t ReadSize( void );
void CheckSize( int type, size_t size );
fileSize_t ReadSize( void );
void CheckSize( int type, fileSize_t size );
void ArchiveData( int type, void *data, size_t size );
void CheckWrite( void );
void WriteType( int type );
void WriteSize( size_t size );
void WriteSize(fileSize_t size );
public:
CLASS_PROTOTYPE( Archiver );
+1 -1
View File
@@ -5,7 +5,7 @@
// ConsoleEvent
//===============================
MEM_BlockAlloc< ConsoleEvent, MEM_BLOCKSIZE > ConsoleEvent_allocator;
MEM_BlockAlloc<ConsoleEvent> ConsoleEvent_allocator;
CLASS_DECLARATION(Event, ConsoleEvent, NULL)
{
+1 -1
View File
@@ -24,4 +24,4 @@ public:
virtual void ErrorInternal(Listener* l, str text);
};
extern MEM_BlockAlloc< ConsoleEvent, MEM_BLOCKSIZE > ConsoleEvent_allocator;
extern MEM_BlockAlloc<ConsoleEvent> ConsoleEvent_allocator;
+1
View File
@@ -54,6 +54,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "soundman.h"
#include "../qcommon/qfiles.h"
#include "g_spawn.h"
#include <tiki.h>
// Generic entity events
Event EV_SoundDone
+1 -37
View File
@@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "lodthing.h"
#include "viewthing.h"
#include "playerbot.h"
#include <tiki.h>
#ifdef WIN32
#include <intrin.h>
@@ -109,32 +110,6 @@ void QDECL G_Error( int type, const char *fmt, ... )
assert( !text );
}
void* G_Malloc( int size )
{
return SV_Malloc( size );
}
void G_Free( void *ptr )
{
int zoneId = *( int * )( ( byte * )ptr - 4 );
int size = ( int )( ( byte * )ptr - 16 );
assert( ptr );
if( zoneId == 0xC057 )
return;
assert( zoneId == 0x2015 );
if( zoneId != 0x2015 )
return;
assert( *( unsigned int * )( *( unsigned int * )size + size - 4 ) == 0x2015 );
if( *( unsigned int * )( *( unsigned int * )size + size - 4 ) != 0x2015 )
return;
SV_Free( ptr );
}
/*
===============
G_ExitWithError
@@ -255,9 +230,6 @@ void G_InitGame( int levelTime, int randomSeed )
G_Printf( "gamename: %s\n", GAMEVERSION );
G_Printf( "gamedate: %s\n", __DATE__ );
SV_Error = gi.Error;
gi.Error = G_Error;
srand( randomSeed );
CVAR_Init();
@@ -1470,14 +1442,6 @@ gameExport_t * GetGameAPI(gameImport_t * import)
{
gi = *import;
#ifdef _DEBUG
//SV_Malloc = gi.Malloc;
///gi.Malloc = G_Malloc;
//SV_Free = gi.Free;
//gi.Free = G_Free;
#endif
globals.apiversion = GAME_API_VERSION;
globals.AllowPaused = G_AllowPaused;
+1
View File
@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "g_spawn.h"
#include <scriptvariable.h>
#include <object.h>
#include <tiki.h>
#ifdef GAME_DLL
#include "../game/entity.h"
+1
View File
@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "actor.h"
#include "player.h"
#include "playerbot.h"
#include <tiki.h>
typedef struct {
char oldShader[MAX_QPATH];
+4 -3
View File
@@ -1651,7 +1651,7 @@ void PathSearch::ArchiveStaticLoad
arc.ArchiveInteger( &total_children );
size = total_nodes + total_children * ( sizeof( pathway_t ) * 2 ) + nodecount * ( sizeof( PathNode ) / 2 );
size *= 2;
size *= sizeof(void*) / 2;
gi.DPrintf( "%d memory allocated for navigation.\n", size );
@@ -3260,7 +3260,8 @@ PathNode *PathSearch::FindCornerNodeForExactPath
if (!PathSearch::FindPath(enemy->origin, pSelf->origin, pSelf, fMaxPath, 0, 0.0, 100))
return NULL;
int iDepth;
size_t iDepth = 0;
for (PathNode* pParentNode = Node->Parent; pParentNode; pParentNode = pParentNode->Parent, iDepth++)
{
pPathNode[iDepth] = pParentNode;
@@ -3291,7 +3292,7 @@ PathNode *PathSearch::FindCornerNodeForExactPath
}
}
int index = i - 1;
size_t index = i - 1;
if (index < iDepth)
{
if (index)
+2 -2
View File
@@ -7086,8 +7086,6 @@ void Player::ClientThink
client->cmd_angles[ 1 ] = SHORT2ANGLE( current_ucmd->angles[ 1 ] );
client->cmd_angles[ 2 ] = SHORT2ANGLE( current_ucmd->angles[ 2 ] );
ClientInactivityTimer();
if( g_gametype->integer && g_smoothClients->integer && !IsSubclassOfBot() )
{
VectorCopy( client->ps.velocity, edict->s.pos.trDelta );
@@ -7098,6 +7096,8 @@ void Player::ClientThink
VectorClear( edict->s.pos.trDelta );
edict->s.pos.trTime = 0;
}
ClientInactivityTimer();
}
void Player::UpdateEnemies
+24 -96
View File
@@ -127,7 +127,7 @@ void ScriptMaster::Archive( Archiver& arc )
num = ScriptClass_allocator.Count();
arc.ArchiveInteger( &num );
MEM_BlockAlloc_enum< ScriptClass, MEM_BLOCKSIZE > en = ScriptClass_allocator;
MEM_BlockAlloc_enum<ScriptClass> en = ScriptClass_allocator;
for( scr = en.NextElement(); scr != NULL; scr = en.NextElement() )
{
scr->ArchiveInternal( arc );
@@ -396,11 +396,6 @@ void ScriptMaster::Reset( qboolean samemap )
}
}
void ScriptMaster::AddContextSwitch( ScriptThread *thread )
{
m_contextSwitches.AddUniqueObject( thread );
}
const_str ScriptMaster::AddString( const char *s )
{
return StringDict.addKeyIndex( s );
@@ -456,7 +451,7 @@ ScriptThread *ScriptMaster::CreateScriptThread( ScriptClass *scriptClass, const_
if( !m_pCodePos )
{
ScriptError( "ScriptMaster::CreateScriptThread: label '%s' does not exist in '%s'.", Director.GetString( label ).c_str(), scriptClass->Filename().c_str() );
throw ScriptException( "ScriptMaster::CreateScriptThread: label '%s' does not exist in '%s'.", Director.GetString( label ).c_str(), scriptClass->Filename().c_str() );
}
return CreateScriptThread( scriptClass, m_pCodePos );
@@ -487,7 +482,7 @@ ScriptThread *ScriptMaster::CreateThread( GameScript *scr, str label, Listener *
}
catch( ScriptException& exc )
{
glbs.DPrintf( "ScriptMaster::CreateThread: %s\n", exc.string.c_str() );
gi.DPrintf( "ScriptMaster::CreateThread: %s\n", exc.string.c_str() );
return NULL;
}
}
@@ -514,7 +509,7 @@ ScriptThread *ScriptMaster::CurrentThread( void )
assert( m_CurrentThread );
if( !m_CurrentThread )
{
ScriptError( "current thread is NULL" );
throw ScriptException( "current thread is NULL" );
}
return m_CurrentThread;
@@ -537,7 +532,7 @@ void ScriptMaster::ExecuteThread( GameScript *scr, str label )
}
catch( ScriptException& exc )
{
glbs.DPrintf( "ScriptMaster::ExecuteThread: %s\n", exc.string.c_str() );
gi.DPrintf( "ScriptMaster::ExecuteThread: %s\n", exc.string.c_str() );
}
}
@@ -563,7 +558,7 @@ void ScriptMaster::ExecuteThread( GameScript *scr, str label, Event &parms )
}
catch( ScriptException& exc )
{
glbs.DPrintf( "ScriptMaster::ExecuteThread: %s\n", exc.string.c_str() );
gi.DPrintf( "ScriptMaster::ExecuteThread: %s\n", exc.string.c_str() );
}
}
@@ -603,7 +598,7 @@ GameScript *ScriptMaster::GetGameScript( str filename, qboolean recompile )
{
if( !scr->successCompile )
{
ScriptError( "Script '%s' was not properly loaded\n", filename.c_str() );
throw ScriptException( "Script '%s' was not properly loaded\n", filename.c_str() );
}
return scr;
@@ -613,7 +608,7 @@ GameScript *ScriptMaster::GetGameScript( str filename, qboolean recompile )
if( scr && recompile )
{
Container< ScriptClass * > list;
MEM_BlockAlloc_enum< ScriptClass, MEM_BLOCKSIZE > en = ScriptClass_allocator;
MEM_BlockAlloc_enum<ScriptClass> en = ScriptClass_allocator;
ScriptClass *scriptClass;
m_GameScripts[ s ] = NULL;
@@ -651,7 +646,7 @@ GameScript *ScriptMaster::GetGameScriptInternal( str& filename )
if( filename.length() >= MAX_QPATH )
{
glbs.Error( ERR_DROP, "Script filename '%s' exceeds maximum length of %d\n", filename.c_str(), MAX_QPATH );
gi.Error( ERR_DROP, "Script filename '%s' exceeds maximum length of %d\n", filename.c_str(), MAX_QPATH );
}
scr = m_GameScripts[ StringDict.findKeyIndex( filename ) ];
@@ -662,7 +657,7 @@ GameScript *ScriptMaster::GetGameScriptInternal( str& filename )
}
strcpy( filepath, filename.c_str() );
glbs.FS_CanonicalFilename( filepath );
gi.FS_CanonicalFilename( filepath );
filename = filepath;
scr = new GameScript( filename );
@@ -675,20 +670,20 @@ GameScript *ScriptMaster::GetGameScriptInternal( str& filename )
return scr;
}
sourceLength = glbs.FS_ReadFile( filename.c_str(), &sourceBuffer, true );
sourceLength = gi.FS_ReadFile( filename.c_str(), &sourceBuffer, true );
if( sourceLength < 0 )
{
ScriptError( "Can't find '%s'\n", filename.c_str() );
throw ScriptException( "Can't find '%s'\n", filename.c_str() );
}
scr->Load( sourceBuffer, sourceLength );
glbs.FS_FreeFile( sourceBuffer );
gi.FS_FreeFile( sourceBuffer );
if( !scr->successCompile )
{
ScriptError( "Script '%s' was not properly loaded", filename.c_str() );
throw ScriptException( "Script '%s' was not properly loaded", filename.c_str() );
}
return scr;
@@ -702,7 +697,7 @@ GameScript *ScriptMaster::GetScript( str filename, qboolean recompile )
}
catch( ScriptException& exc )
{
glbs.Printf( "ScriptMaster::GetScript: %s\n", exc.string.c_str() );
gi.DPrintf( "ScriptMaster::GetScript: %s\n", exc.string.c_str() );
}
return NULL;
@@ -716,31 +711,16 @@ GameScript *ScriptMaster::GetScript( const_str filename, qboolean recompile )
}
catch( ScriptException& exc )
{
glbs.Printf( "ScriptMaster::GetScript: %s\n", exc.string.c_str() );
gi.DPrintf( "ScriptMaster::GetScript: %s\n", exc.string.c_str() );
}
return NULL;
}
void ScriptMaster::Init()
{
maxTime = 5000;
// it's more preferable to disable it. Thread can use the wait command instead.
// Context switch can be a problem in a trigger thread, parm.other can be sometimes invalid due to another thread
// calling some trigger function
m_bAllowContextSwitch = false;
AddString( "" );
}
void ScriptMaster::ExecuteRunning( void )
{
int num;
int i;
int startTime;
ScriptThread *thread;
if( stackCount )
{
@@ -765,59 +745,7 @@ void ScriptMaster::ExecuteRunning( void )
level.m_LoopProtection = true;
}
startTime = glbs.Milliseconds();
// Handle context switches
while( ( num = m_contextSwitches.NumObjects() ) )
{
Container< SafePtr< ScriptThread > > containerCopy = m_contextSwitches;
m_contextSwitches.FreeObjectList();
for( i = 1; i <= num; i++ )
{
thread = containerCopy.ObjectAt( i );
if
(
thread &&
thread->GetThreadState() == THREAD_CONTEXT_SWITCH
)
{
ScriptThread *context = thread->GetWaitingContext();
if( context == NULL )
{
// thread will continue from the context switch
m_CurrentThread = thread;
thread->m_ScriptVM->m_ThreadState = THREAD_RUNNING;
thread->m_ScriptVM->Execute();
}
else if( context->GetThreadState() != THREAD_CONTEXT_SWITCH )
{
// execute the parent thread as the child thread is waiting for something else
m_CurrentThread = thread;
thread->SetWaitingContext( NULL );
thread->m_ScriptVM->m_ThreadState = THREAD_RUNNING;
thread->m_ScriptVM->Execute();
}
else
{
// re-add the thread due to it still waiting for its child thread to continue
// from the context switch
m_contextSwitches.AddObject( thread );
}
}
}
// interrupt in case of infinite loop
if( glbs.Milliseconds() - startTime >= Director.maxTime )
{
break;
}
}
startTime = gi.Milliseconds();
}
void ScriptMaster::SetTime( int time )
@@ -833,7 +761,7 @@ void ScriptMaster::PrintStatus( void )
int iThreadRunning = 0;
int iThreadWaiting = 0;
int iThreadSuspended = 0;
MEM_BlockAlloc_enum< ScriptClass, MEM_BLOCKSIZE > en = ScriptClass_allocator;
MEM_BlockAlloc_enum<ScriptClass> en = ScriptClass_allocator;
ScriptClass *scriptClass;
char szBuffer[ MAX_STRING_TOKENS ];
@@ -883,7 +811,7 @@ void ScriptMaster::PrintStatus( void )
status += str( m_GameScripts.size() ) + " total scripts compiled\n";
status += str( iThreadNum ) + " total threads ( " + str( iThreadRunning ) + " running thread(s), " + str( iThreadWaiting ) + " waiting thread(s), " + str( iThreadSuspended ) + " suspended thread(s) )\n";
glbs.Printf( status.c_str() );
gi.Printf( status.c_str() );
}
void ScriptMaster::PrintThread( int iThreadNum )
@@ -892,7 +820,7 @@ void ScriptMaster::PrintThread( int iThreadNum )
ScriptVM *vm;
bool bFoundThread = false;
str status;
MEM_BlockAlloc_enum< ScriptClass, MEM_BLOCKSIZE > en = ScriptClass_allocator;
MEM_BlockAlloc_enum<ScriptClass> en = ScriptClass_allocator;
ScriptClass *scriptClass;
for( scriptClass = en.NextElement(); scriptClass != NULL; scriptClass = en.NextElement() )
@@ -916,7 +844,7 @@ void ScriptMaster::PrintThread( int iThreadNum )
if( !bFoundThread )
{
glbs.Printf( "Can't find thread id %i.\n", iThreadNum );
gi.Printf( "Can't find thread id %i.\n", iThreadNum );
}
status = "-------------------------\n";
@@ -988,12 +916,12 @@ void ScriptMaster::PrintThread( int iThreadNum )
status += "\n";
}
glbs.Printf( status.c_str() );
gi.Printf( status.c_str() );
}
static int bLoadForMap( char *psMapsBuffer, const char *name )
{
cvar_t *mapname = glbs.Cvar_Get( "mapname", "", 0 );
cvar_t *mapname = gi.Cvar_Get( "mapname", "", 0 );
const char *token;
if( !strncmp( "test", mapname->string, sizeof( "test" ) ) ) {
@@ -1085,7 +1013,7 @@ void ScriptMaster::RegisterAliasInternal
if( bLoadForMap( psMapsBuffer, ev->GetString( 1 ) ) )
{
glbs.GlobalAlias_Add( ev->GetString( 1 ), ev->GetString( 2 ), parameters );
gi.GlobalAlias_Add( ev->GetString( 1 ), ev->GetString( 2 ), parameters );
if( bCache )
CacheResource( ev->GetString( 2 ) );
-7
View File
@@ -70,10 +70,6 @@ public:
con_arrayset< str, str > StringDict; // const strings (improve performance)
int iPaused; // num times paused
// Context switch variables
bool m_bAllowContextSwitch;
Container< SafePtr< ScriptThread > > m_contextSwitches; // Threads to be prepared for context switching
protected:
static const char *ConstStrings[];
@@ -89,8 +85,6 @@ public:
virtual void Archive( Archiver &arc );
void ArchiveString( Archiver& arc, const_str& s );
void AddContextSwitch( ScriptThread *thread );
const_str AddString( const char *s );
const_str AddString( str& s );
const_str GetString( const char *s );
@@ -132,7 +126,6 @@ public:
void CloseGameScript();
void Reset( qboolean samemap = false );
void Init();
void ExecuteRunning();
void SetTime( int time );
+4054 -4192
View File
File diff suppressed because it is too large. Load diff
+103 -106
View File
@@ -42,15 +42,9 @@ public:
void DelayExecute(Event& ev);
void DelayExecute(Event* ev = NULL);
void AllowContextSwitch(bool allow = true);
ScriptClass* GetScriptClass(void);
str ScriptThread::FileName(void);
int GetThreadState(void);
ScriptThread* GetWaitingContext(void);
void SetWaitingContext(ScriptThread* thread);
void HandleContextSwitch(ScriptThread* childThread);
void Pause(void);
void ScriptExecute(ScriptVariable* data, int dataSize, ScriptVariable& returnValue);
@@ -58,54 +52,8 @@ public:
void Wait(float time);
void StartTiming(float time);
void StartTiming(void);
bool CanScriptTracePrint();
void CanSwitchTeams(Event* ev);
bool CanScriptTracePrint(void);
void CharToInt(Event* ev);
void Conprintf(Event* ev);
void CreateHUD(Event* ev);
void Earthquake(Event* ev);
void FadeSound(Event* ev);
void FileOpen(Event* ev);
void FileWrite(Event* ev);
void FileRead(Event* ev);
void FileClose(Event* ev);
void FileEof(Event* ev);
void FileSeek(Event* ev);
void FileTell(Event* ev);
void FileRewind(Event* ev);
void FilePutc(Event* ev);
void FilePuts(Event* ev);
void FileGetc(Event* ev);
void FileGets(Event* ev);
void FileError(Event* ev);
void FileFlush(Event* ev);
void FileExists(Event* ev);
void FileReadAll(Event* ev);
void FileSaveAll(Event* ev);
void FileRemove(Event* ev);
void FileRename(Event* ev);
void FileCopy(Event* ev);
void FileReadPak(Event* ev);
void FileList(Event* ev);
void FileNewDirectory(Event* ev);
void FileRemoveDirectory(Event* ev);
void FlagClear(Event* ev);
void FlagInit(Event* ev);
void FlagSet(Event* ev);
void FlagWait(Event* ev);
void GetAreaEntities(Event* ev);
void GetArrayKeys(Event* ev);
void GetArrayValues(Event* ev);
void GetEntArray(Event* ev);
void GetPlayerNetname(Event* ev);
void GetPlayerIP(Event* ev);
void GetPlayerPing(Event* ev);
void GetPlayerClientNum(Event* ev);
void GetTime(Event* ev);
void GetDate(Event* ev);
void GetTimeZone(Event* ev);
void PregMatch(Event* ev);
void EventHudDraw3d(Event* ev);
void EventHudDrawTimer(Event* ev);
void EventHudDrawShader(Event* ev);
@@ -116,59 +64,6 @@ public:
void EventHudDrawAlpha(Event* ev);
void EventHudDrawString(Event* ev);
void EventHudDrawFont(Event* ev);
void EventIHudDraw3d(Event* ev);
void EventIHudDrawShader(Event* ev);
void EventIHudDrawAlign(Event* ev);
void EventIHudDrawRect(Event* ev);
void EventIHudDrawVirtualSize(Event* ev);
void EventIHudDrawColor(Event* ev);
void EventIHudDrawAlpha(Event* ev);
void EventIHudDrawString(Event* ev);
void EventIHudDrawFont(Event* ev);
void EventIHudDrawTimer(Event* ev);
void EventIsArray(Event* ev);
void EventIsDefined(Event* ev);
void EventIsOnGround(Event* ev);
void EventIsOutOfBounds(Event* ev);
void GetEntity(Event* ev);
void MathCos(Event* ev);
void MathSin(Event* ev);
void MathTan(Event* ev);
void MathACos(Event* ev);
void MathASin(Event* ev);
void MathATan(Event* ev);
void MathATan2(Event* ev);
void MathCosH(Event* ev);
void MathSinH(Event* ev);
void MathTanH(Event* ev);
void MathExp(Event* ev);
void MathFrexp(Event* ev);
void MathLdexp(Event* ev);
void MathLog(Event* ev);
void MathLog10(Event* ev);
void MathModf(Event* ev);
void MathPow(Event* ev);
void MathSqrt(Event* ev);
void MathCeil(Event* ev);
void MathFloor(Event* ev);
void MathFmod(Event* ev);
void StringBytesCopy(Event* ev);
void Md5File(Event* ev);
void Md5String(Event* ev);
void RegisterEvent(Event* ev);
void RestoreSound(Event* ev);
void RemoveArchivedClass(Event* ev);
void ServerStufftext(Event* ev);
void SetTimer(Event* ev);
void TeamGetScore(Event* ev);
void TeamSetScore(Event* ev);
void TeamSwitchDelay(Event* ev);
void TraceDetails(Event* ev);
void TypeOfVariable(Event* ev);
void UnregisterEvent(Event* ev);
void VisionGetNaked(Event* ev);
void VisionSetNaked(Event* ev);
void CancelWaiting(Event* ev);
void GetAbs(Event* ev);
void AddObjective(Event* ev);
@@ -295,4 +190,106 @@ public:
void TriggerEvent(Event* ev);
void ServerEvent(Event* ev);
void MissionFailed(Event* ev);
/**
* Non-MOHAA stuff
*/
void CanSwitchTeams(Event* ev);
void CharToInt(Event* ev);
void Conprintf(Event* ev);
void CreateHUD(Event* ev);
void Earthquake(Event* ev);
void FadeSound(Event* ev);
void FileOpen(Event* ev);
void FileWrite(Event* ev);
void FileRead(Event* ev);
void FileClose(Event* ev);
void FileEof(Event* ev);
void FileSeek(Event* ev);
void FileTell(Event* ev);
void FileRewind(Event* ev);
void FilePutc(Event* ev);
void FilePuts(Event* ev);
void FileGetc(Event* ev);
void FileGets(Event* ev);
void FileError(Event* ev);
void FileFlush(Event* ev);
void FileExists(Event* ev);
void FileReadAll(Event* ev);
void FileSaveAll(Event* ev);
void FileRemove(Event* ev);
void FileRename(Event* ev);
void FileCopy(Event* ev);
void FileReadPak(Event* ev);
void FileList(Event* ev);
void FileNewDirectory(Event* ev);
void FileRemoveDirectory(Event* ev);
void FlagClear(Event* ev);
void FlagInit(Event* ev);
void FlagSet(Event* ev);
void FlagWait(Event* ev);
void GetAreaEntities(Event* ev);
void GetArrayKeys(Event* ev);
void GetArrayValues(Event* ev);
void GetEntArray(Event* ev);
void GetPlayerNetname(Event* ev);
void GetPlayerIP(Event* ev);
void GetPlayerPing(Event* ev);
void GetPlayerClientNum(Event* ev);
void GetTime(Event* ev);
void GetDate(Event* ev);
void GetTimeZone(Event* ev);
void PregMatch(Event* ev);
void EventIHudDraw3d(Event* ev);
void EventIHudDrawShader(Event* ev);
void EventIHudDrawAlign(Event* ev);
void EventIHudDrawRect(Event* ev);
void EventIHudDrawVirtualSize(Event* ev);
void EventIHudDrawColor(Event* ev);
void EventIHudDrawAlpha(Event* ev);
void EventIHudDrawString(Event* ev);
void EventIHudDrawFont(Event* ev);
void EventIHudDrawTimer(Event* ev);
void EventIsArray(Event* ev);
void EventIsDefined(Event* ev);
void EventIsOnGround(Event* ev);
void EventIsOutOfBounds(Event* ev);
void GetEntity(Event* ev);
void MathCos(Event* ev);
void MathSin(Event* ev);
void MathTan(Event* ev);
void MathACos(Event* ev);
void MathASin(Event* ev);
void MathATan(Event* ev);
void MathATan2(Event* ev);
void MathCosH(Event* ev);
void MathSinH(Event* ev);
void MathTanH(Event* ev);
void MathExp(Event* ev);
void MathFrexp(Event* ev);
void MathLdexp(Event* ev);
void MathLog(Event* ev);
void MathLog10(Event* ev);
void MathModf(Event* ev);
void MathPow(Event* ev);
void MathSqrt(Event* ev);
void MathCeil(Event* ev);
void MathFloor(Event* ev);
void MathFmod(Event* ev);
void StringBytesCopy(Event* ev);
void Md5File(Event* ev);
void Md5String(Event* ev);
void RegisterEvent(Event* ev);
void RestoreSound(Event* ev);
void RemoveArchivedClass(Event* ev);
void ServerStufftext(Event* ev);
void SetTimer(Event* ev);
void TeamGetScore(Event* ev);
void TeamSetScore(Event* ev);
void TraceDetails(Event* ev);
void TypeOfVariable(Event* ev);
void UnregisterEvent(Event* ev);
void VisionGetNaked(Event* ev);
void VisionSetNaked(Event* ev);
void CancelWaiting(Event* ev);
};
+3 -34
View File
@@ -53,7 +53,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// ScriptClass
//====================
MEM_BlockAlloc< ScriptClass, MEM_BLOCKSIZE > ScriptClass_allocator;
MEM_BlockAlloc<ScriptClass> ScriptClass_allocator;
CLASS_DECLARATION(Listener, ScriptClass, NULL)
{
@@ -112,7 +112,7 @@ ScriptClass::ScriptClass()
ScriptClass::~ScriptClass()
{
if (m_Script == NULL) {
ScriptError("Attempting to delete dead class.");
throw ScriptException("Attempting to delete dead class.");
}
KillThreads();
@@ -426,7 +426,7 @@ Listener* ScriptClass::GetSelf()
//====================
MEM_BlockAlloc< ScriptVM, char[256] > ScriptVM_allocator;
MEM_BlockAlloc<ScriptVM> ScriptVM_allocator;
/*
====================
@@ -2290,37 +2290,6 @@ bool ScriptVM::EventThrow(Event* ev)
return false;
}
/*
====================
AllowContextSwitch
====================
*/
void ScriptVM::AllowContextSwitch(bool allow)
{
m_bAllowContextSwitch = allow;
}
/*
====================
RequestContextSwitch
Requests a context switch
====================
*/
void ScriptVM::RequestContextSwitch(void)
{
if (!m_bAllowContextSwitch || !Director.m_bAllowContextSwitch) {
return;
}
//glbs.DPrintf( "Performing context switch\n" );
Director.AddContextSwitch(m_Thread);
m_ThreadState = THREAD_CONTEXT_SWITCH;
Suspend();
}
bool ScriptVM::CanScriptTracePrint
(
void
+1 -4
View File
@@ -322,12 +322,9 @@ public:
void EventGoto( Event *ev );
bool EventThrow( Event *ev );
void AllowContextSwitch( bool allow = true );
void RequestContextSwitch();
bool CanScriptTracePrint( void );
};
extern MEM_BlockAlloc< ScriptClass, MEM_BLOCKSIZE > ScriptClass_allocator;
extern MEM_BlockAlloc<ScriptClass> ScriptClass_allocator;
#endif
+1
View File
@@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "actor.h"
#include "bg_local.h"
#include <tiki.h>
CLASS_DECLARATION( Sentient, SimpleActor, NULL )
{
+82 -69
View File
@@ -1939,33 +1939,33 @@ Event EV_TriggerChangeLevel_SpawnSpot
);
CLASS_DECLARATION( Trigger, TriggerChangeLevel, "trigger_changelevel" )
{
{ &EV_Trigger_Effect, &TriggerChangeLevel::ChangeLevel },
{ &EV_TriggerChangeLevel_Map, &TriggerChangeLevel::SetMap },
{ &EV_TriggerChangeLevel_SpawnSpot, &TriggerChangeLevel::SetSpawnSpot },
{ &EV_Trigger_SetThread, &TriggerChangeLevel::SetThread },
{ NULL, NULL }
};
{
{ &EV_Trigger_Effect, &TriggerChangeLevel::ChangeLevel },
{ &EV_TriggerChangeLevel_Map, &TriggerChangeLevel::SetMap },
{ &EV_TriggerChangeLevel_SpawnSpot, &TriggerChangeLevel::SetSpawnSpot },
{ NULL, NULL }
};
TriggerChangeLevel::TriggerChangeLevel()
{
if (LoadingSavegame)
{
if ( LoadingSavegame )
{
// Archive function will setup all necessary data
return;
}
// default level change thread
label.Set( "LevelComplete" );
respondto = spawnflags ^ TRIGGER_PLAYERS;
// Archive function will setup all necessary data
return;
}
// default level change thread
map = STRING_EMPTY;
spawnspot = STRING_EMPTY;
}
void TriggerChangeLevel::SetMap
(
Event *ev
)
{
map = ev->GetString( 1 );
map = ev->GetConstString( 1 );
}
void TriggerChangeLevel::SetSpawnSpot
@@ -1973,80 +1973,93 @@ void TriggerChangeLevel::SetSpawnSpot
Event *ev
)
{
spawnspot = ev->GetString( 1 );
}
void TriggerChangeLevel::SetThread
(
Event *ev
)
{
// We have to handle calling the thread ourselves, so clear out Trigger's thread variable
label.Set( "" );
change_label.SetThread( ev->GetValue( 1 ) );
}
{
spawnspot = ev->GetConstString(1);
}
void TriggerChangeLevel::ChangeLevel
(
Event *ev
)
{
SafePtr<Entity> safeThis = this;
Entity* other;
other = ev->GetEntity(1);
if (level.intermissiontime)
{
Entity *other;
other = ev->GetEntity( 1 );
if ( level.intermissiontime )
{
// already activated
return;
}
}
// if noexit, do a ton of damage to other
if ( DM_FLAG( DF_SAME_LEVEL ) && other != world )
{
other->Damage( this, other, 10 * other->max_health, other->origin, vec_zero, vec_zero, 1000, 0, MOD_CRUSH );
if (DM_FLAG(DF_SAME_LEVEL) && other != world)
{
other->Damage(this, other, 10 * other->max_health, other->origin, vec_zero, vec_zero, 1000, 0, MOD_CRUSH);
return;
}
//
// make sure we execute the thread before changing
//
if ( change_label.IsSet() )
{
change_label.Execute();
}
if ( spawnspot.length() )
{
G_BeginIntermission( ( map + "$" + spawnspot ).c_str(), TRANS_BSP );
}
else
{
G_BeginIntermission( map.c_str(), TRANS_BSP );
}
}
const char *TriggerChangeLevel::Map
(
void
)
parm.other.Clear();
parm.owner.Clear();
Unregister(STRING_TRIGGER);
// Scripts could potentially remove the trigger
// So make sure it's safe to continue here
if (!safeThis) {
return;
}
//
// make sure we execute the thread before changing
//
label.Execute();
if (g_gametype->integer)
{
return map.c_str();
G_BeginIntermission2();
return;
}
const char *TriggerChangeLevel::SpawnSpot
(
void
)
if (spawnflags & VISIBLE)
{
return spawnspot.c_str();
level.intermissiontime = level.time;
G_FadeOut(1.0);
G_FadeSound(1.0);
// Set the next map
level.nextmap = Director.GetString(map);
}
if (spawnspot != STRING_EMPTY)
{
G_BeginIntermission(Director.GetString(map) + "$" + Director.GetString(spawnspot), TRANS_BSP);
}
else
{
G_BeginIntermission(Director.GetString(map));
}
}
const char *TriggerChangeLevel::Map(void)
{
return Director.GetString(map).c_str();
}
const char *TriggerChangeLevel::SpawnSpot(void)
{
return Director.GetString(spawnspot).c_str();
}
void TriggerChangeLevel::Archive(Archiver& arc)
{
Trigger::Archive(arc);
Director.ArchiveString(arc, map);
Director.ArchiveString(arc, spawnspot);
}
/*****************************************************************************/
/*QUAKED trigger_use (1 0 0) ? VISIBLE x NOT_PLAYERS MONSTERS
+15 -28
View File
@@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "glb_local.h"
#include "animate.h"
#include <gamescript.h>
#include "gamescript.h"
class ScriptMaster;
@@ -430,35 +430,22 @@ inline void RandomSpeaker::Archive
}
class TriggerChangeLevel : public Trigger
{
protected:
str map;
str spawnspot;
ScriptThreadLabel change_label;
{
protected:
const_str map;
const_str spawnspot;
public:
CLASS_PROTOTYPE( TriggerChangeLevel );
public:
CLASS_PROTOTYPE(TriggerChangeLevel);
TriggerChangeLevel();
void SetMap( Event *ev );
void SetSpawnSpot( Event *ev );
void SetThread( Event *ev );
void ChangeLevel( Event *ev );
const char *Map( void );
const char *SpawnSpot( void );
virtual void Archive( Archiver &arc );
};
inline void TriggerChangeLevel::Archive
(
Archiver &arc
)
{
Trigger::Archive( arc );
arc.ArchiveString( &map );
arc.ArchiveString( &spawnspot );
}
TriggerChangeLevel();
void SetMap(Event* ev);
void SetSpawnSpot(Event* ev);
void ChangeLevel(Event* ev);
const char* Map(void);
const char* SpawnSpot(void);
virtual void Archive(Archiver& arc);
};
class TriggerExit : public Trigger
{
+7
View File
@@ -125,6 +125,13 @@ extern "C" {
if( node->next ) node->next->prev = node->prev; \
}
#define LL_SafeRemoveRoot(rootnode,node,next,prev) \
{ \
if (rootnode == node) rootnode = (node->next); \
if (node->prev) node->prev->next = node->next; \
if (node->next) node->next->prev = node->prev; \
}
#define LL_SafeAdd(rootnode, newnode, next, prev) \
{ \
(newnode)->next = NULL; \
+23 -25
View File
@@ -705,16 +705,14 @@ void Alias_ListFindRandomRange( AliasList_t *list, const char *alias, int *min_i
convalias[ length ] = 0;
r = 0;
l = list->num_in_list - 1;
if( l >= 0 )
l = 0;
r = list->num_in_list - 1;
if (r >= 0)
{
int __res;
do
{
__res = ( l + r ) >> 1;
diff = strncmp( convalias, list->sorted_list[ __res ]->alias_name, length );
index = (l + r) >> 1;
diff = strncmp( convalias, list->sorted_list[index]->alias_name, length );
if( diff == 0 )
{
@@ -722,49 +720,49 @@ void Alias_ListFindRandomRange( AliasList_t *list, const char *alias, int *min_i
}
else if( diff > 0 )
{
r = __res + 1;
l = index + 1;
}
else
{
l = __res - 1;
r = index - 1;
}
} while( l >= r );
} while (r >= l);
if( l >= r )
if(l >= r)
{
numfound = 0;
*min_index = __res;
*max_index = __res;
*min_index = index;
*max_index = index;
totalfoundweight = 0.f;
for( i = __res; i >= 0; i-- )
ptr = &list->sorted_list[index];
for(i = 0; i < index; i++, ptr--)
{
ptr = &list->sorted_list[ i ];
if( strncmp( convalias, ( *ptr )->alias_name, length ) )
if (strncmp(convalias, (*ptr)->alias_name, length)) {
break;
}
if( numfound <= 63 && ( *ptr )->alias_name[ length ] != '_' )
{
foundlist[ numfound++ ] = *ptr;
totalfoundweight += ( *ptr )->weight;
foundlist[numfound++] = *ptr;
totalfoundweight += (*ptr)->weight;
*min_index = i;
}
}
ptr = &list->sorted_list[ __res + 1 ];
ptr = &list->sorted_list[index + 1];
for( i = 0; i < list->num_in_list; i++ )
for(i = index + 1; i < list->num_in_list; i++, ptr++)
{
ptr = &list->sorted_list[ __res + i + 1 ];
if( strncmp( convalias, ( *ptr )->alias_name, length ) )
if (strncmp(convalias, (*ptr)->alias_name, length)) {
break;
}
if( numfound <= 63 && ( *ptr )->alias_name[ length ] != '_' )
{
foundlist[ numfound++ ] = *ptr;
totalfoundweight += ( *ptr )->weight;
*max_index = __res + i + 1;
*max_index = i;
}
}
+2 -2
View File
@@ -34,10 +34,10 @@ extern "C" {
const char * Alias_Find( const char * alias );
qboolean Alias_Add( const char * alias, const char * name, const char * parameters );
qboolean Alias_Delete( const char * alias );
const char * Alias_FindRandom( const char * alias, AliasListNode_t **ret );
const char * Alias_FindRandom( const char * alias, struct AliasListNode_s **ret );
void Alias_Dump( void );
void Alias_Clear( void );
AliasList_t *Alias_GetGlobalList();
struct AliasList_s *Alias_GetGlobalList();
int S_ChannelNameToNum( const char *pszName );
const char *S_ChannelNumToName( int iChannel );
+4 -2
View File
@@ -237,10 +237,10 @@ void *Class::operator new( size_t s )
p = ( size_t * )gi.Malloc( s );
#elif defined ( CGAME_DLL )
p = ( size_t * )cgi.Malloc( s );
#else
p = (size_t*)Z_Malloc(s);
#endif
*p = s;
totalmemallocated += s;
numclassesallocated++;
@@ -260,6 +260,8 @@ void Class::operator delete( void *ptr )
gi.Free( p );
#elif defined ( CGAME_DLL )
cgi.Free( p );
#else
Z_Free(p);
#endif
}
Loaded 100 of 145 files, more files were not shown because too many files have changed in this diff. Show more