2011-02-18 14:31:32 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
Copyright (C) 1999-2005 Id Software, Inc.
|
|
|
|
|
|
|
|
This file is part of Quake III Arena source code.
|
|
|
|
|
|
|
|
Quake III Arena 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.
|
|
|
|
|
|
|
|
Quake III Arena 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 Quake III Arena source code; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
#include "q_shared.h"
|
|
|
|
#include "qcommon.h"
|
|
|
|
|
ioquake3 resync to revision 2398 from 2369.
This is the last ioquake3 revision before ioquake3 changed from subversion to git at the beginning of 2013.
#5808 - Include and use .glsl in source (rend2)
#5812 - Use refdef's coordinates when drawing to screen shadow fbo, and separate depth texture and screen texture coordinates in glsl shaders.
Include Rend2 renderer in MacOSX bundle
Include OpenGL1 and Rend2 renderers in MacOSX UB
Include Rend2 renderer in NSIS installer.
Include OpenGL1 and Rend2 renderers in Loki Setup Installer.
Have NSIS uninstaller delete rend2.
Split light sample into direct and ambient parts when using deluxemaps or per-vertex light vectors. Fixes #5813.
Fix writting voip data in demos (broke in r2102).
Fix server ignoring client move commands if voip data is included.
Allow changing cl_voip without restarting.
Fix assert failing in CL_ParseVoip() while flipping cl_voip off and on.
Only declare var_SampleToView in lightall shader when it is actually used.
Fix a couple files not ending with a newline.
Fix clients being able to reset their player state and respawn using donedl.
Fix passing arg9 (qvm only), arg10, and arg11 to vmMain for native libs and non-i386 compiled or interpated qvms. (Currently they aren't use in vmMain in game, cgame, or ui.)
Fix passing args[11] to args[15] from vm to engine on ppc64 and sparc64. Some of the args are used by game bot prediction syscalls. May have been causing bugs. Note: This was fixed for x86_64 in r2163.
Fix reconnect command to work after leaving server. (#5794)
Fix dedicated server crashing when using MSG_ReadDelta*, though it only happens if someone modifies the engine. (#5449)
Makefile fixes for OpenBSD by Jonathan Gray. (#5728)
Save all arguments from connect for reconnect command.
Remove unnecessary localhost check from reconnect command.
Support r_srgb even without hardware support. Also tweak default autoexposure/tonemap settings to look good on both r_srgb 0 and 1.
Changed the MacOS-X build system to make UB's containing i386 and x86_64 arches and made make-macosx.sh not build UB's but only standard binaries
Fix spectator client being switched from follow to free after map_restart if following a client with a higher client number.
Fix client unlinking issue caused by ent->s.number being set to followed client's ps->clientNum after map_restart. Reported by Ensiform.
Changes from Ensiform:
- In G_AddBot, try to allocate clientNum before doing anything else.
- In G_AddBot, don't set SVF_BOT and inuse. It's done in ClientConnect, plus inuse causes ClientDisconnect to be run for no reason.
- In G_AddBot, only set skill in bot useinfo once.
- Avoid using cl->ps.clientNum to check if cl is a bot.
Fix bot skill format so it doesn't always have a space at the beginning of it.
More fixes to the macosx buildsystem. This removes the SDL Framework and makes use of a SDL library that is position independant. This also brings back PPC builds into the UB and also as a standa alone build choice.
Have make-macosx.sh require the user to specify which architecture she/he wants to build for and suggest building UB's if the user is unaware of what architectures are
Lets list all the valid options.
2017-07-09 21:21:12 +00:00
|
|
|
// Max number of arguments to pass from engine to vm's vmMain function.
|
|
|
|
// command number + 12 arguments
|
|
|
|
#define MAX_VMMAIN_ARGS 13
|
|
|
|
|
|
|
|
// Max number of arguments to pass from a vm to engine's syscall handler function for the vm.
|
|
|
|
// syscall number + 15 arguments
|
|
|
|
#define MAX_VMSYSCALL_ARGS 16
|
|
|
|
|
2011-07-26 08:52:24 +00:00
|
|
|
// don't change, this is hardcoded into x86 VMs, opStack protection relies
|
|
|
|
// on this
|
|
|
|
#define OPSTACK_SIZE 1024
|
2011-02-18 14:31:32 +00:00
|
|
|
#define OPSTACK_MASK (OPSTACK_SIZE-1)
|
|
|
|
|
|
|
|
// don't change
|
2012-09-15 03:03:44 +00:00
|
|
|
// Hardcoded in q3asm a reserved at end of bss
|
2011-02-18 14:31:32 +00:00
|
|
|
#define PROGRAM_STACK_SIZE 0x10000
|
|
|
|
#define PROGRAM_STACK_MASK (PROGRAM_STACK_SIZE-1)
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
OP_UNDEF,
|
|
|
|
|
|
|
|
OP_IGNORE,
|
|
|
|
|
|
|
|
OP_BREAK,
|
|
|
|
|
|
|
|
OP_ENTER,
|
|
|
|
OP_LEAVE,
|
|
|
|
OP_CALL,
|
|
|
|
OP_PUSH,
|
|
|
|
OP_POP,
|
|
|
|
|
|
|
|
OP_CONST,
|
|
|
|
OP_LOCAL,
|
|
|
|
|
|
|
|
OP_JUMP,
|
|
|
|
|
|
|
|
//-------------------
|
|
|
|
|
|
|
|
OP_EQ,
|
|
|
|
OP_NE,
|
|
|
|
|
|
|
|
OP_LTI,
|
|
|
|
OP_LEI,
|
|
|
|
OP_GTI,
|
|
|
|
OP_GEI,
|
|
|
|
|
|
|
|
OP_LTU,
|
|
|
|
OP_LEU,
|
|
|
|
OP_GTU,
|
|
|
|
OP_GEU,
|
|
|
|
|
|
|
|
OP_EQF,
|
|
|
|
OP_NEF,
|
|
|
|
|
|
|
|
OP_LTF,
|
|
|
|
OP_LEF,
|
|
|
|
OP_GTF,
|
|
|
|
OP_GEF,
|
|
|
|
|
|
|
|
//-------------------
|
|
|
|
|
|
|
|
OP_LOAD1,
|
|
|
|
OP_LOAD2,
|
|
|
|
OP_LOAD4,
|
|
|
|
OP_STORE1,
|
|
|
|
OP_STORE2,
|
|
|
|
OP_STORE4, // *(stack[top-1]) = stack[top]
|
|
|
|
OP_ARG,
|
|
|
|
|
|
|
|
OP_BLOCK_COPY,
|
|
|
|
|
|
|
|
//-------------------
|
|
|
|
|
|
|
|
OP_SEX8,
|
|
|
|
OP_SEX16,
|
|
|
|
|
|
|
|
OP_NEGI,
|
|
|
|
OP_ADD,
|
|
|
|
OP_SUB,
|
|
|
|
OP_DIVI,
|
|
|
|
OP_DIVU,
|
|
|
|
OP_MODI,
|
|
|
|
OP_MODU,
|
|
|
|
OP_MULI,
|
|
|
|
OP_MULU,
|
|
|
|
|
|
|
|
OP_BAND,
|
|
|
|
OP_BOR,
|
|
|
|
OP_BXOR,
|
|
|
|
OP_BCOM,
|
|
|
|
|
|
|
|
OP_LSH,
|
|
|
|
OP_RSHI,
|
|
|
|
OP_RSHU,
|
|
|
|
|
|
|
|
OP_NEGF,
|
|
|
|
OP_ADDF,
|
|
|
|
OP_SUBF,
|
|
|
|
OP_DIVF,
|
|
|
|
OP_MULF,
|
|
|
|
|
|
|
|
OP_CVIF,
|
|
|
|
OP_CVFI
|
|
|
|
} opcode_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef int vmptr_t;
|
|
|
|
|
|
|
|
typedef struct vmSymbol_s {
|
|
|
|
struct vmSymbol_s *next;
|
|
|
|
int symValue;
|
|
|
|
int profileCount;
|
|
|
|
char symName[1]; // variable sized
|
|
|
|
} vmSymbol_t;
|
|
|
|
|
|
|
|
#define VM_OFFSET_PROGRAM_STACK 0
|
|
|
|
#define VM_OFFSET_SYSTEM_CALL 4
|
|
|
|
|
|
|
|
struct vm_s {
|
|
|
|
// DO NOT MOVE OR CHANGE THESE WITHOUT CHANGING THE VM_OFFSET_* DEFINES
|
|
|
|
// USED BY THE ASM CODE
|
|
|
|
int programStack; // the vm may be recursively entered
|
|
|
|
intptr_t (*systemCall)( intptr_t *parms );
|
|
|
|
|
|
|
|
//------------------------------------
|
|
|
|
|
2011-07-26 08:52:24 +00:00
|
|
|
char name[MAX_QPATH];
|
|
|
|
void *searchPath; // hint for FS_ReadFileDir()
|
2011-02-18 14:31:32 +00:00
|
|
|
|
|
|
|
// for dynamic linked modules
|
|
|
|
void *dllHandle;
|
2023-03-03 04:26:22 +00:00
|
|
|
vmMainProc entryPoint;
|
2011-02-18 14:31:32 +00:00
|
|
|
void (*destroy)(vm_t* self);
|
|
|
|
|
|
|
|
// for interpreted modules
|
|
|
|
qboolean currentlyInterpreting;
|
|
|
|
|
|
|
|
qboolean compiled;
|
|
|
|
byte *codeBase;
|
2011-07-26 08:52:24 +00:00
|
|
|
int entryOfs;
|
2011-02-18 14:31:32 +00:00
|
|
|
int codeLength;
|
|
|
|
|
2011-07-26 08:52:24 +00:00
|
|
|
intptr_t *instructionPointers;
|
2011-02-18 14:31:32 +00:00
|
|
|
int instructionCount;
|
|
|
|
|
|
|
|
byte *dataBase;
|
|
|
|
int dataMask;
|
2017-07-10 01:33:41 +00:00
|
|
|
int dataAlloc; // actually allocated
|
2011-02-18 14:31:32 +00:00
|
|
|
|
|
|
|
int stackBottom; // if programStack < stackBottom, error
|
|
|
|
|
|
|
|
int numSymbols;
|
|
|
|
struct vmSymbol_s *symbols;
|
|
|
|
|
|
|
|
int callLevel; // counts recursive VM_Call
|
|
|
|
int breakFunction; // increment breakCount on function entry to this
|
|
|
|
int breakCount;
|
|
|
|
|
|
|
|
byte *jumpTableTargets;
|
|
|
|
int numJumpTableTargets;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
extern vm_t *currentVM;
|
|
|
|
extern int vm_debugLevel;
|
|
|
|
|
|
|
|
void VM_Compile( vm_t *vm, vmHeader_t *header );
|
|
|
|
int VM_CallCompiled( vm_t *vm, int *args );
|
|
|
|
|
|
|
|
void VM_PrepareInterpreter( vm_t *vm, vmHeader_t *header );
|
|
|
|
int VM_CallInterpreted( vm_t *vm, int *args );
|
|
|
|
|
|
|
|
vmSymbol_t *VM_ValueToFunctionSymbol( vm_t *vm, int value );
|
|
|
|
int VM_SymbolToValue( vm_t *vm, const char *symbol );
|
|
|
|
const char *VM_ValueToSymbol( vm_t *vm, int value );
|
|
|
|
void VM_LogSyscalls( int *args );
|
2011-07-26 08:52:24 +00:00
|
|
|
|
|
|
|
void VM_BlockCopy(unsigned int dest, unsigned int src, size_t n);
|