diff --git a/include/QF/progs.h b/include/QF/progs.h index e086c06a9..7bd6972b3 100644 --- a/include/QF/progs.h +++ b/include/QF/progs.h @@ -134,7 +134,7 @@ int NUM_FOR_BAD_EDICT(progs_t *pr, edict_t *e); #define P_INT(p,n) P_var (p, n, integer) #define P_UINT(p,n) P_var (p, n, uinteger) #define P_EDICT(p,n) ((edict_t *)(PR_edicts (p) + P_INT (p, n))) -#define P_EDICTNUM(p,n) NUM_FOR_EDICT (p, P_EDICT (p, n)); +#define P_EDICTNUM(p,n) NUM_FOR_EDICT (p, P_EDICT (p, n)) #define P_VECTOR(p,n) P_var (p, n, vector) #define P_STRING(p,n) PR_GetString (p, P_var (p, n, string)) #define P_FUNCTION(p,n) P_var (p, n, func) diff --git a/libs/console/menu.c b/libs/console/menu.c index 49650bb36..2ece35e63 100644 --- a/libs/console/menu.c +++ b/libs/console/menu.c @@ -140,9 +140,9 @@ menu_add_item (menu_item_t *m, menu_item_t *i) static void bi_Menu_Begin (progs_t *pr) { - int x = G_INT (pr, OFS_PARM0); - int y = G_INT (pr, OFS_PARM1); - const char *text = G_STRING (pr, OFS_PARM2); + int x = P_INT (pr, 0); + int y = P_INT (pr, 1); + const char *text = P_STRING (pr, 2); menu_item_t *m = calloc (sizeof (menu_item_t), 1); m->x = x; @@ -157,33 +157,33 @@ bi_Menu_Begin (progs_t *pr) static void bi_Menu_FadeScreen (progs_t *pr) { - menu->fadescreen = G_INT (pr, OFS_PARM0); + menu->fadescreen = P_INT (pr, 0); } static void bi_Menu_Draw (progs_t *pr) { - menu->draw = G_FUNCTION (pr, OFS_PARM0); + menu->draw = P_FUNCTION (pr, 0); } static void bi_Menu_EnterHook (progs_t *pr) { - menu->enter_hook = G_FUNCTION (pr, OFS_PARM0); + menu->enter_hook = P_FUNCTION (pr, 0); } static void bi_Menu_LeaveHook (progs_t *pr) { - menu->leave_hook = G_FUNCTION (pr, OFS_PARM0); + menu->leave_hook = P_FUNCTION (pr, 0); } static void bi_Menu_Pic (progs_t *pr) { - int x = G_INT (pr, OFS_PARM0); - int y = G_INT (pr, OFS_PARM1); - const char *name = G_STRING (pr, OFS_PARM2); + int x = P_INT (pr, 0); + int y = P_INT (pr, 1); + const char *name = P_STRING (pr, 2); menu_pic_t *pic = malloc (sizeof (menu_pic_t)); pic->x = x; @@ -196,9 +196,9 @@ bi_Menu_Pic (progs_t *pr) static void bi_Menu_CenterPic (progs_t *pr) { - int x = G_INT (pr, OFS_PARM0); - int y = G_INT (pr, OFS_PARM1); - const char *name = G_STRING (pr, OFS_PARM2); + int x = P_INT (pr, 0); + int y = P_INT (pr, 1); + const char *name = P_STRING (pr, 2); menu_pic_t *pic = malloc (sizeof (menu_pic_t)); qpic_t *qpic = Draw_CachePic (name, 1); @@ -217,11 +217,11 @@ bi_Menu_CenterPic (progs_t *pr) static void bi_Menu_Item (progs_t *pr) { - int x = G_INT (pr, OFS_PARM0); - int y = G_INT (pr, OFS_PARM1); - const char *text = G_STRING (pr, OFS_PARM2); - func_t func = G_FUNCTION (pr, OFS_PARM3); - int allkeys = G_INT (pr, OFS_PARM4); + int x = P_INT (pr, 0); + int y = P_INT (pr, 1); + const char *text = P_STRING (pr, 2); + func_t func = P_FUNCTION (pr, 3); + int allkeys = P_INT (pr, 4); menu_item_t *mi = calloc (sizeof (menu_item_t), 1); mi->x = x; @@ -236,7 +236,7 @@ bi_Menu_Item (progs_t *pr) static void bi_Menu_Cursor (progs_t *pr) { - func_t func = G_FUNCTION (pr, OFS_PARM0); + func_t func = P_FUNCTION (pr, 0); menu->cursor = func; } @@ -244,7 +244,7 @@ bi_Menu_Cursor (progs_t *pr) static void bi_Menu_KeyEvent (progs_t *pr) { - func_t func = G_FUNCTION (pr, OFS_PARM0); + func_t func = P_FUNCTION (pr, 0); menu->keyevent = func; } @@ -258,7 +258,7 @@ bi_Menu_End (progs_t *pr) static void bi_Menu_TopMenu (progs_t *pr) { - const char *name = G_STRING (pr, OFS_PARM0); + const char *name = P_STRING (pr, 0); if (top_menu) free ((char*)top_menu); @@ -268,7 +268,7 @@ bi_Menu_TopMenu (progs_t *pr) static void bi_Menu_SelectMenu (progs_t *pr) { - const char *name = G_STRING (pr, OFS_PARM0); + const char *name = P_STRING (pr, 0); menu = 0; if (name && *name) @@ -295,7 +295,7 @@ bi_Menu_SelectMenu (progs_t *pr) static void bi_Menu_SetQuit (progs_t *pr) { - func_t func = G_FUNCTION (pr, OFS_PARM0); + func_t func = P_FUNCTION (pr, 0); menu_quit = func; } @@ -312,9 +312,9 @@ static void bi_Menu_GetIndex (progs_t *pr) { if (menu) { - G_INT (pr, OFS_RETURN) = menu->cur_item; + R_INT (pr) = menu->cur_item; } else { - G_INT (pr, OFS_RETURN) = -1; + R_INT (pr) = -1; } } diff --git a/libs/gamecode/builtins/bi_cbuf.c b/libs/gamecode/builtins/bi_cbuf.c index e05e474fb..8ef6b00e1 100644 --- a/libs/gamecode/builtins/bi_cbuf.c +++ b/libs/gamecode/builtins/bi_cbuf.c @@ -36,7 +36,7 @@ static const char rcsid[] = static void bi_Cbuf_AddText (progs_t *pr) { - const char *text = G_STRING (pr, OFS_PARM0); + const char *text = P_STRING (pr, 0); Cbuf_AddText (text); } @@ -44,7 +44,7 @@ bi_Cbuf_AddText (progs_t *pr) static void bi_Cbuf_InsertText (progs_t *pr) { - const char *text = G_STRING (pr, OFS_PARM0); + const char *text = P_STRING (pr, 0); Cbuf_InsertText (text); } diff --git a/libs/gamecode/builtins/bi_cmd.c b/libs/gamecode/builtins/bi_cmd.c index 4f726d799..4455b91a7 100644 --- a/libs/gamecode/builtins/bi_cmd.c +++ b/libs/gamecode/builtins/bi_cmd.c @@ -90,15 +90,15 @@ bi_Cmd_AddCommand (progs_t *pr) { cmd_resources_t *res = PR_Resources_Find (pr, "Cmd"); bi_cmd_t *cmd = malloc (sizeof (bi_cmd_t)); - char *name = strdup (G_STRING (pr, OFS_PARM0)); - func_t func = G_FUNCTION (pr, OFS_PARM1); + char *name = strdup (P_STRING (pr, 0)); + func_t func = P_FUNCTION (pr, 1); if (!cmd || !name || !Cmd_AddCommand (name, (void(*)(void))bi_cmd_f, "CSQC command")) { if (name) free (name); if (cmd) free (cmd); - G_INT (pr, OFS_RETURN) = 0; + R_INT (pr) = 0; return; } cmd->name = name; @@ -107,7 +107,7 @@ bi_Cmd_AddCommand (progs_t *pr) Hash_Add (bi_cmds, cmd); cmd->next = res->cmds; res->cmds = cmd; - G_INT (pr, OFS_RETURN) = 1; + R_INT (pr) = 1; } static void @@ -127,31 +127,31 @@ bi_cmd_clear (progs_t *pr, void *data) static void bi_Cmd_Argc (progs_t *pr) { - G_INT (pr, OFS_RETURN) = Cmd_Argc (); + R_INT (pr) = Cmd_Argc (); } static void bi_Cmd_Argv (progs_t *pr) { - RETURN_STRING (pr, Cmd_Argv (G_INT (pr, OFS_PARM0))); + RETURN_STRING (pr, Cmd_Argv (P_INT (pr, 0))); } static void bi_Cmd_Args (progs_t *pr) { - RETURN_STRING (pr, Cmd_Args (G_INT (pr, OFS_PARM0))); + RETURN_STRING (pr, Cmd_Args (P_INT (pr, 0))); } static void bi_Cmd_Argu (progs_t *pr) { - RETURN_STRING (pr, Cmd_Argu (G_INT (pr, OFS_PARM0))); + RETURN_STRING (pr, Cmd_Argu (P_INT (pr, 0))); } static void bi_Cmd_Return (progs_t *pr) { - Cmd_Return (G_STRING (pr, OFS_PARM0)); + Cmd_Return (P_STRING (pr, 0)); } //Cmd_CheckParm diff --git a/libs/gamecode/builtins/bi_cvar.c b/libs/gamecode/builtins/bi_cvar.c index 50cf00ca2..adc6f7e90 100644 --- a/libs/gamecode/builtins/bi_cvar.c +++ b/libs/gamecode/builtins/bi_cvar.c @@ -50,7 +50,7 @@ static const char rcsid[] = static void bi_Cvar_GetCvarString (progs_t *pr) { - const char *varname = G_STRING (pr, OFS_PARM0); + const char *varname = P_STRING (pr, 0); RETURN_STRING (pr, Cvar_VariableString (varname)); } diff --git a/libs/gamecode/builtins/bi_file.c b/libs/gamecode/builtins/bi_file.c index 7fd5f1b14..5c238272d 100644 --- a/libs/gamecode/builtins/bi_file.c +++ b/libs/gamecode/builtins/bi_file.c @@ -117,8 +117,8 @@ file_writeable (char *path) static void bi_File_Open (progs_t *pr) { - const char *pth = G_STRING (pr, OFS_PARM0); - const char *mode = G_STRING (pr, OFS_PARM1); + const char *pth = P_STRING (pr, 0); + const char *mode = P_STRING (pr, 1); char *path= Hunk_TempAlloc (strlen (pth) + 1); char *p, *d; int h; @@ -185,7 +185,7 @@ bi_File_Open (progs_t *pr) if (*p == '/') p++; } - //printf ("'%s' '%s'\n", G_STRING (pr, OFS_PARM0), path); + //printf ("'%s' '%s'\n", P_STRING (pr, 0), path); if (!path[0]) goto error; if (path[0] == '.' && path[1] == '.' && (path[2] == '/' || path [2] == 0)) @@ -204,16 +204,16 @@ bi_File_Open (progs_t *pr) goto error; if (!(handles[h] = Qopen (va ("%s/%s", com_gamedir, path), mode))) goto error; - G_INT (pr, OFS_RETURN) = h + 1; + R_INT (pr) = h + 1; return; error: - G_INT (pr, OFS_RETURN) = 0; + R_INT (pr) = 0; } static void bi_File_Close (progs_t *pr) { - int h = G_INT (pr, OFS_PARM0) - 1; + int h = P_INT (pr, 0) - 1; if (h < 0 || h >= MAX_HANDLES || !handles[h]) return; @@ -224,11 +224,11 @@ bi_File_Close (progs_t *pr) static void bi_File_GetLine (progs_t *pr) { - int h = G_INT (pr, OFS_PARM0) - 1; + int h = P_INT (pr, 0) - 1; const char *s; if (h < 0 || h >= MAX_HANDLES || !handles[h]) { - G_INT (pr, OFS_RETURN) = 0; + R_INT (pr) = 0; return; } s = Qgetline (handles[h]); diff --git a/libs/gamecode/builtins/bi_inputline.c b/libs/gamecode/builtins/bi_inputline.c index f36eab91f..728c61d85 100644 --- a/libs/gamecode/builtins/bi_inputline.c +++ b/libs/gamecode/builtins/bi_inputline.c @@ -78,9 +78,9 @@ bi_InputLine_Create (progs_t *pr) il_resources_t *res = PR_Resources_Find (pr, "InputLine"); inputline_t **line = 0; int i; - int lines = G_INT (pr, OFS_PARM0); - int size = G_INT (pr, OFS_PARM1); - int prompt = G_INT (pr, OFS_PARM2); + int lines = P_INT (pr, 0); + int size = P_INT (pr, 1); + int prompt = P_INT (pr, 2); pr_type_t *handle; for (i = 0; i < res->max_lines; i++) @@ -90,26 +90,26 @@ bi_InputLine_Create (progs_t *pr) } if (!line) { Sys_Printf ("out of resources\n"); - G_INT (pr, OFS_RETURN) = 0; + R_INT (pr) = 0; return; } *line = Con_CreateInputLine (lines, size, prompt); if (!*line) { Sys_Printf ("failed to create inputline\n"); - G_INT (pr, OFS_RETURN) = 0; + R_INT (pr) = 0; return; } handle = PR_Zone_Malloc (pr, sizeof (inputline_t *)); *(inputline_t**)handle = *line; - G_INT (pr, OFS_RETURN) = handle - pr->pr_globals; + R_INT (pr) = handle - pr->pr_globals; } static void bi_InputLine_SetWidth (progs_t *pr) { - inputline_t *line = get_inputline (pr, G_INT (pr, OFS_PARM0), + inputline_t *line = get_inputline (pr, P_INT (pr, 0), "InputLine_SetWidth"); - int width = G_INT (pr, OFS_PARM1); + int width = P_INT (pr, 1); line->width = width; } @@ -119,7 +119,7 @@ bi_InputLine_Destroy (progs_t *pr) { il_resources_t *res = PR_Resources_Find (pr, "InputLine"); pr_type_t *handle; - int arg = G_INT (pr, OFS_PARM0); + int arg = P_INT (pr, 0); int i; inputline_t *line; @@ -144,8 +144,7 @@ bi_InputLine_Destroy (progs_t *pr) static void bi_InputLine_Clear (progs_t *pr) { - inputline_t *line = get_inputline (pr, G_INT (pr, OFS_PARM0), - "InputLine_Clear"); + inputline_t *line = get_inputline (pr, P_INT (pr, 0), "InputLine_Clear"); Con_ClearTyping (line); } @@ -153,9 +152,8 @@ bi_InputLine_Clear (progs_t *pr) static void bi_InputLine_Process (progs_t *pr) { - inputline_t *line = get_inputline (pr, G_INT (pr, OFS_PARM0), - "InputLine_Process"); - int ch = G_INT (pr, OFS_PARM1); + inputline_t *line = get_inputline (pr, P_INT (pr, 0), "InputLine_Process"); + int ch = P_INT (pr, 1); Con_ProcessInputLine (line, ch); } @@ -168,9 +166,8 @@ bi_InputLine_Process (progs_t *pr) static void bi_InputLine_SetText (progs_t *pr) { - inputline_t *il = get_inputline (pr, G_INT (pr, OFS_PARM0), - "InputLine_SetText"); - const char *str = G_STRING (pr, OFS_PARM1); + inputline_t *il = get_inputline (pr, P_INT (pr, 0), "InputLine_SetText"); + const char *str = P_STRING (pr, 1); /* this was segfault trap: il->lines[il->edit_line][0] is promt character @@ -187,8 +184,7 @@ bi_InputLine_SetText (progs_t *pr) static void bi_InputLine_GetText (progs_t *pr) { - inputline_t *il = get_inputline (pr, G_INT (pr, OFS_PARM0), - "InputLine_GetText"); + inputline_t *il = get_inputline (pr, P_INT (pr, 0), "InputLine_GetText"); RETURN_STRING(pr, il->lines[il->edit_line]+1); } @@ -196,11 +192,10 @@ bi_InputLine_GetText (progs_t *pr) static void bi_InputLine_Draw (progs_t *pr) { - inputline_t *il = get_inputline (pr, G_INT (pr, OFS_PARM0), - "InputLine_Draw"); - int x = G_INT (pr, OFS_PARM1); - int y = G_INT (pr, OFS_PARM2); - int cursor = G_INT (pr, OFS_PARM3); + inputline_t *il = get_inputline (pr, P_INT (pr, 0), "InputLine_Draw"); + int x = P_INT (pr, 1); + int y = P_INT (pr, 2); + int cursor = P_INT (pr, 3); const char *s = il->lines[il->edit_line] + il->scroll; if (il->scroll) { diff --git a/libs/gamecode/builtins/bi_keys.c b/libs/gamecode/builtins/bi_keys.c index 2f8ce498f..54d3bfd67 100644 --- a/libs/gamecode/builtins/bi_keys.c +++ b/libs/gamecode/builtins/bi_keys.c @@ -50,9 +50,9 @@ static const char rcsid[] = static void bi_Key_SetBinding (progs_t *pr) { - int target = G_INT (pr, OFS_PARM0); - int keynum = G_INT (pr, OFS_PARM1); - const char *binding = G_STRING (pr, OFS_PARM2); + int target = P_INT (pr, 0); + int keynum = P_INT (pr, 1); + const char *binding = P_STRING (pr, 2); if(strlen(binding) == 0 || binding[0] == '\0') { binding = NULL; /* unbind a binding */ @@ -69,9 +69,9 @@ bi_Key_SetBinding (progs_t *pr) static void bi_Key_LookupBinding (progs_t *pr) { - int target = G_INT (pr, OFS_PARM0); - int bindnum = G_INT (pr, OFS_PARM1); - const char *binding = G_STRING (pr, OFS_PARM2); + int target = P_INT (pr, 0); + int bindnum = P_INT (pr, 1); + const char *binding = P_STRING (pr, 2); int i; knum_t keynum = -1; const char *keybind = NULL; @@ -88,7 +88,7 @@ bi_Key_LookupBinding (progs_t *pr) } } - G_INT (pr, OFS_RETURN) = keynum; + R_INT (pr) = keynum; }; /* @@ -99,8 +99,8 @@ bi_Key_LookupBinding (progs_t *pr) static void bi_Key_CountBinding (progs_t *pr) { - int target = G_INT (pr, OFS_PARM0); - const char *binding = G_STRING (pr, OFS_PARM1); + int target = P_INT (pr, 0); + const char *binding = P_STRING (pr, 1); int i, res = 0; const char *keybind = NULL; @@ -112,7 +112,7 @@ bi_Key_CountBinding (progs_t *pr) } } - G_INT (pr, OFS_RETURN) = res; + R_INT (pr) = res; }; @@ -124,7 +124,7 @@ bi_Key_CountBinding (progs_t *pr) static void bi_Key_KeynumToString (progs_t *pr) { - int keynum = G_INT (pr, OFS_PARM0); + int keynum = P_INT (pr, 0); RETURN_STRING (pr, Key_KeynumToString (keynum)); }; diff --git a/libs/gamecode/builtins/bi_strhash.c b/libs/gamecode/builtins/bi_strhash.c index f694a39a6..061cd8797 100644 --- a/libs/gamecode/builtins/bi_strhash.c +++ b/libs/gamecode/builtins/bi_strhash.c @@ -122,7 +122,7 @@ bi_StringHash_Create (progs_t *pr) res->cnt_hashes++; // increase cnt of allocated hashes } - G_INT (pr, OFS_RETURN) = hash_id; + R_INT (pr) = hash_id; } /* @@ -134,12 +134,12 @@ static void bi_StringHash_Destroy (progs_t *pr) { strh_resources_t* res = PR_Resources_Find (pr, "StringHash"); - int hash_id = G_INT (pr, OFS_PARM0); + int hash_id = P_INT (pr, 0); str_hash *sh = NULL; int i,d; if(hash_id >= res->cnt_hashes || hash_id < 0) { - G_INT (pr, OFS_RETURN) = 0; + R_INT (pr) = 0; return; } sh = res->hashes[hash_id]; @@ -172,7 +172,7 @@ bi_StringHash_Destroy (progs_t *pr) free(sh->elements); // free the list pointer sh->elements = NULL; sh->cnt_elements = 0; - G_INT (pr, OFS_RETURN) = 1; + R_INT (pr) = 1; } @@ -188,10 +188,10 @@ static void bi_StringHash_Set (progs_t *pr) { strh_resources_t* res = PR_Resources_Find (pr, "StringHash"); - int hash_id = G_INT (pr, OFS_PARM0); - const char *key = G_STRING (pr, OFS_PARM1); - const char *val = G_STRING (pr, OFS_PARM2); - int val_id = G_INT (pr, OFS_PARM3); + int hash_id = P_INT (pr, 0); + const char *key = P_STRING (pr, 1); + const char *val = P_STRING (pr, 2); + int val_id = P_INT (pr, 3); str_hash *sh = NULL; int i,found_fl=0; @@ -200,7 +200,7 @@ bi_StringHash_Set (progs_t *pr) (hash_id >= res->cnt_hashes || hash_id < 0) || (val_id < 0 || val_id >= MAX_SH_VALUES)) { - G_INT (pr, OFS_RETURN) = 0; + R_INT (pr) = 0; return; } sh = res->hashes[hash_id]; @@ -236,7 +236,7 @@ bi_StringHash_Set (progs_t *pr) sh->cnt_elements++; } - G_INT (pr, OFS_RETURN) = 1; + R_INT (pr) = 1; return; } @@ -253,10 +253,10 @@ static void bi_StringHash_SetIdx (progs_t *pr) { strh_resources_t* res = PR_Resources_Find (pr, "StringHash"); - int hash_id = G_INT (pr, OFS_PARM0); - int idx = G_INT (pr, OFS_PARM1); - const char *val = G_STRING (pr, OFS_PARM2); - int val_id = G_INT (pr, OFS_PARM3); + int hash_id = P_INT (pr, 0); + int idx = P_INT (pr, 1); + const char *val = P_STRING (pr, 2); + int val_id = P_INT (pr, 3); str_hash *sh = NULL; // validate the hash ID @@ -264,7 +264,7 @@ bi_StringHash_SetIdx (progs_t *pr) (hash_id >= res->cnt_hashes || hash_id < 0) || (val_id < 0 || val_id >= MAX_SH_VALUES)) { - G_INT (pr, OFS_RETURN) = 0; + R_INT (pr) = 0; return; } sh = res->hashes[hash_id]; @@ -273,7 +273,7 @@ bi_StringHash_SetIdx (progs_t *pr) if(sh->elements[idx] == NULL) PR_Error(pr, "NULL hash-element found -> not supposed!"); - G_INT (pr, OFS_RETURN) = 0; + R_INT (pr) = 0; return; } @@ -283,7 +283,7 @@ bi_StringHash_SetIdx (progs_t *pr) sh->elements[idx]->values[val_id] = strdup(val); - G_INT (pr, OFS_RETURN) = 1; + R_INT (pr) = 1; return; } @@ -296,9 +296,9 @@ static void bi_StringHash_Get (progs_t *pr) { strh_resources_t* res = PR_Resources_Find (pr, "StringHash"); - int hash_id = G_INT (pr, OFS_PARM0); - const char *key = G_STRING (pr, OFS_PARM1); - int val_id = G_INT (pr, OFS_PARM2); + int hash_id = P_INT (pr, 0); + const char *key = P_STRING (pr, 1); + int val_id = P_INT (pr, 2); str_hash *sh = NULL; int i,found_fl=0; const char *retstr = NULL; @@ -339,17 +339,17 @@ static void bi_StringHash_Length (progs_t *pr) { strh_resources_t* res = PR_Resources_Find (pr, "StringHash"); - int hash_id = G_INT (pr, OFS_PARM0); + int hash_id = P_INT (pr, 0); str_hash *sh = NULL; // validate the hash ID if(res->hashes == NULL || hash_id >= res->cnt_hashes || hash_id < 0) { - G_INT (pr, OFS_RETURN) = 0; + R_INT (pr) = 0; return; } sh = res->hashes[hash_id]; - G_INT (pr, OFS_RETURN) = sh->cnt_elements; + R_INT (pr) = sh->cnt_elements; } /* @@ -363,9 +363,9 @@ static void bi_StringHash_GetIdx (progs_t *pr) { strh_resources_t* res = PR_Resources_Find (pr, "StringHash"); - int hash_id = G_INT (pr, OFS_PARM0); - int idx = G_INT (pr, OFS_PARM1); - int val_id = G_INT (pr, OFS_PARM2); + int hash_id = P_INT (pr, 0); + int idx = P_INT (pr, 1); + int val_id = P_INT (pr, 2); str_hash *sh = NULL; const char *retstr = NULL; diff --git a/libs/gamecode/builtins/bi_string.c b/libs/gamecode/builtins/bi_string.c index 65669ba36..79ec5bdec 100644 --- a/libs/gamecode/builtins/bi_string.c +++ b/libs/gamecode/builtins/bi_string.c @@ -49,9 +49,9 @@ static const char rcsid[] = static void bi_String_ReplaceChar (progs_t *pr) { - char old = G_INT (pr, OFS_PARM0); - char new = G_INT (pr, OFS_PARM1); - const char *src = G_STRING (pr, OFS_PARM2); + char old = P_INT (pr, 0); + char new = P_INT (pr, 1); + const char *src = P_STRING (pr, 2); const char *s; char *dst = Hunk_TempAlloc (strlen (src) + 1); char *d; @@ -73,9 +73,9 @@ bi_String_ReplaceChar (progs_t *pr) static void bi_String_Cut (progs_t *pr) { - char pos = G_INT (pr, OFS_PARM0); - char len = G_INT (pr, OFS_PARM1); - const char *str = G_STRING (pr, OFS_PARM2); + char pos = P_INT (pr, 0); + char len = P_INT (pr, 1); + const char *str = P_STRING (pr, 2); char *dst = Hunk_TempAlloc ((strlen (str) - len) + 1); int cnt; @@ -96,9 +96,9 @@ bi_String_Cut (progs_t *pr) static void bi_String_Len (progs_t *pr) { - const char *str = G_STRING (pr, OFS_PARM0); + const char *str = P_STRING (pr, 0); - G_INT (pr, OFS_RETURN) = strlen(str); + R_INT (pr) = strlen(str); } /* @@ -110,14 +110,14 @@ bi_String_Len (progs_t *pr) static void bi_String_GetChar (progs_t *pr) { - const char *str = G_STRING (pr, OFS_PARM0); - int pos = G_INT (pr, OFS_PARM1); + const char *str = P_STRING (pr, 0); + int pos = P_INT (pr, 1); int ret = 0; if(pos > 0 && pos < strlen(str)) { ret = (int)str[pos]; } - G_INT (pr, OFS_RETURN) = ret; + R_INT (pr) = ret; } diff --git a/libs/gamecode/builtins/pr_cmds.c b/libs/gamecode/builtins/pr_cmds.c index 08848ff13..cfceeefad 100644 --- a/libs/gamecode/builtins/pr_cmds.c +++ b/libs/gamecode/builtins/pr_cmds.c @@ -88,7 +88,7 @@ PF_normalize (progs_t *pr) float *value1; vec3_t newvalue; - value1 = G_VECTOR (pr, OFS_PARM0); + value1 = P_VECTOR (pr, 0); new = value1[0] * value1[0] + value1[1] * value1[1] + value1[2] * value1[2]; @@ -103,7 +103,7 @@ PF_normalize (progs_t *pr) newvalue[2] = value1[2] * new; } - VectorCopy (newvalue, G_VECTOR (pr, OFS_RETURN)); + VectorCopy (newvalue, R_VECTOR (pr)); } /* @@ -117,13 +117,13 @@ PF_vlen (progs_t *pr) float new; float *value1; - value1 = G_VECTOR (pr, OFS_PARM0); + value1 = P_VECTOR (pr, 0); new = value1[0] * value1[0] + value1[1] * value1[1] + value1[2] * value1[2]; new = sqrt (new); - G_FLOAT (pr, OFS_RETURN) = new; + R_FLOAT (pr) = new; } /* @@ -137,7 +137,7 @@ PF_vectoyaw (progs_t *pr) float yaw; float *value1; - value1 = G_VECTOR (pr, OFS_PARM0); + value1 = P_VECTOR (pr, 0); if (value1[1] == 0 && value1[0] == 0) yaw = 0; @@ -147,7 +147,7 @@ PF_vectoyaw (progs_t *pr) yaw += 360; } - G_FLOAT (pr, OFS_RETURN) = yaw; + R_FLOAT (pr) = yaw; } /* @@ -161,7 +161,7 @@ PF_vectoangles (progs_t *pr) float forward, pitch, yaw; float *value1; - value1 = G_VECTOR (pr, OFS_PARM0); + value1 = P_VECTOR (pr, 0); if (value1[1] == 0 && value1[0] == 0) { yaw = 0; @@ -180,9 +180,9 @@ PF_vectoangles (progs_t *pr) pitch += 360; } - G_FLOAT (pr, OFS_RETURN + 0) = pitch; - G_FLOAT (pr, OFS_RETURN + 1) = yaw; - G_FLOAT (pr, OFS_RETURN + 2) = 0; + R_FLOAT (pr + 0) = pitch; + R_FLOAT (pr + 1) = yaw; + R_FLOAT (pr + 2) = 0; } /* @@ -199,7 +199,7 @@ PF_random (progs_t *pr) num = (rand () & 0x7fff) / ((float) 0x7fff); - G_FLOAT (pr, OFS_RETURN) = num; + R_FLOAT (pr) = num; } /* @@ -228,7 +228,7 @@ PF_localcmd (progs_t *pr) { const char *str; - str = G_STRING (pr, OFS_PARM0); + str = P_STRING (pr, 0); Cbuf_AddText (str); } #endif @@ -243,9 +243,9 @@ PF_cvar (progs_t *pr) { const char *str; - str = G_STRING (pr, OFS_PARM0); + str = P_STRING (pr, 0); - G_FLOAT (pr, OFS_RETURN) = Cvar_VariableValue (str); + R_FLOAT (pr) = Cvar_VariableValue (str); } /* @@ -259,8 +259,8 @@ PF_cvar_set (progs_t *pr) const char *var_name, *val; cvar_t *var; - var_name = G_STRING (pr, OFS_PARM0); - val = G_STRING (pr, OFS_PARM1); + var_name = P_STRING (pr, 0); + val = P_STRING (pr, 1); var = Cvar_FindVar (var_name); if (!var) var = Cvar_FindAlias (var_name); @@ -277,8 +277,8 @@ PF_fabs (progs_t *pr) { float v; - v = G_FLOAT (pr, OFS_PARM0); - G_FLOAT (pr, OFS_RETURN) = fabs (v); + v = P_FLOAT (pr, 0); + R_FLOAT (pr) = fabs (v); } // entity (entity start, .string field, string match) find = #5; @@ -292,15 +292,15 @@ PF_Find (progs_t *pr) ddef_t *field_def; edict_t *ed; - e = G_EDICTNUM (pr, OFS_PARM0); - f = G_INT (pr, OFS_PARM1); + e = P_EDICTNUM (pr, 0); + f = P_INT (pr, 1); field_def = ED_FieldAtOfs (pr, f); if (!field_def) PR_RunError (pr, "PF_Find: bad search field"); type = field_def->type & ~DEF_SAVEGLOBAL; if (type == ev_string) { - s = G_STRING (pr, OFS_PARM2); + s = P_STRING (pr, 2); if (!s) PR_RunError (pr, "PF_Find: bad search string"); } @@ -319,19 +319,19 @@ PF_Find (progs_t *pr) RETURN_EDICT (pr, ed); return; case ev_float: - if (G_FLOAT (pr, OFS_PARM2) != E_FLOAT (ed, f)) + if (P_FLOAT (pr, 2) != E_FLOAT (ed, f)) continue; RETURN_EDICT (pr, ed); return; case ev_vector: for (i = 0; i <= 2; i++) - if (G_FLOAT (pr, OFS_PARM2 + i) != E_FLOAT (ed, f + i)) + if (P_FLOAT (pr, 2 + i) != E_FLOAT (ed, f + i)) continue; RETURN_EDICT (pr, ed); return; case ev_integer: case ev_entity: - if (G_INT (pr, OFS_PARM2) != E_INT (ed, f)) + if (P_INT (pr, 2) != E_INT (ed, f)) continue; RETURN_EDICT (pr, ed); return; @@ -364,7 +364,7 @@ PF_traceoff (progs_t *pr) void PF_eprint (progs_t *pr) { - ED_PrintNum (pr, G_EDICTNUM (pr, OFS_PARM0)); + ED_PrintNum (pr, P_EDICTNUM (pr, 0)); } void @@ -378,23 +378,23 @@ PF_rint (progs_t *pr) { float f; - f = G_FLOAT (pr, OFS_PARM0); + f = P_FLOAT (pr, 0); if (f > 0) - G_FLOAT (pr, OFS_RETURN) = (int) (f + 0.5); + R_FLOAT (pr) = (int) (f + 0.5); else - G_FLOAT (pr, OFS_RETURN) = (int) (f - 0.5); + R_FLOAT (pr) = (int) (f - 0.5); } void PF_floor (progs_t *pr) { - G_FLOAT (pr, OFS_RETURN) = floor (G_FLOAT (pr, OFS_PARM0)); + R_FLOAT (pr) = floor (P_FLOAT (pr, 0)); } void PF_ceil (progs_t *pr) { - G_FLOAT (pr, OFS_RETURN) = ceil (G_FLOAT (pr, OFS_PARM0)); + R_FLOAT (pr) = ceil (P_FLOAT (pr, 0)); } /* @@ -408,7 +408,7 @@ PF_nextent (progs_t *pr) int i; edict_t *ent; - i = G_EDICTNUM (pr, OFS_PARM0); + i = P_EDICTNUM (pr, 0); while (1) { i++; if (i == *pr->num_edicts) { @@ -438,7 +438,7 @@ PF_nextent (progs_t *pr) void PF_ftoi (progs_t *pr) { - G_INT (pr, OFS_RETURN) = G_FLOAT (pr, OFS_PARM0); + R_INT (pr) = P_FLOAT (pr, 0); } /* @@ -453,7 +453,7 @@ PF_ftos (progs_t *pr) int i; // trimming 0s idea thanks to Maddes - i = snprintf (string, sizeof (string), "%1.6f", G_FLOAT (pr, OFS_PARM0)) - 1; + i = snprintf (string, sizeof (string), "%1.6f", P_FLOAT (pr, 0)) - 1; for (; i > 0; i--) { if (string[i] == '0') string[i] = '\0'; @@ -475,7 +475,7 @@ PF_ftos (progs_t *pr) void PF_itof (progs_t *pr) { - G_FLOAT (pr, OFS_RETURN) = G_INT (pr, OFS_PARM0); + R_FLOAT (pr) = P_INT (pr, 0); } /* @@ -488,7 +488,7 @@ PF_itos (progs_t *pr) { char string[STRING_BUF]; - snprintf (string, sizeof (string), "%d", G_INT (pr, OFS_PARM0)); + snprintf (string, sizeof (string), "%d", P_INT (pr, 0)); RETURN_STRING (pr, string); } @@ -501,7 +501,7 @@ PF_itos (progs_t *pr) void PF_stof (progs_t *pr) { - G_FLOAT (pr, OFS_RETURN) = atof (G_STRING (pr, OFS_PARM0)); + R_FLOAT (pr) = atof (P_STRING (pr, 0)); } /* @@ -512,7 +512,7 @@ PF_stof (progs_t *pr) void PF_stoi (progs_t *pr) { - G_INT (pr, OFS_RETURN) = atoi (G_STRING (pr, OFS_PARM0)); + R_INT (pr) = atoi (P_STRING (pr, 0)); } /* @@ -525,7 +525,7 @@ PF_stov (progs_t *pr) { float v[3] = {0, 0, 0}; - sscanf (G_STRING (pr, OFS_PARM0), "'%f %f %f'", v, v + 1, v + 2); + sscanf (P_STRING (pr, 0), "'%f %f %f'", v, v + 1, v + 2); RETURN_VECTOR (pr, v); } @@ -541,9 +541,9 @@ PF_vtos (progs_t *pr) char string[STRING_BUF * 3 + 5]; snprintf (string, sizeof (string), "'%5.1f %5.1f %5.1f'", - G_VECTOR (pr, OFS_PARM0)[0], - G_VECTOR (pr, OFS_PARM0)[1], - G_VECTOR (pr, OFS_PARM0)[2]); + P_VECTOR (pr, 0)[0], + P_VECTOR (pr, 0)[1], + P_VECTOR (pr, 0)[2]); RETURN_STRING (pr, string); } @@ -558,8 +558,8 @@ PF_strlen (progs_t *pr) { const char *s; - s = G_STRING (pr, OFS_PARM0); - G_FLOAT (pr, OFS_RETURN) = strlen(s); + s = P_STRING (pr, 0); + R_FLOAT (pr) = strlen(s); } /* @@ -574,20 +574,20 @@ PF_charcount (progs_t *pr) const char *s; int count; - goal = (G_STRING (pr, OFS_PARM0))[0]; + goal = (P_STRING (pr, 0))[0]; if (goal == '\0') { - G_FLOAT (pr, OFS_RETURN) = 0; + R_FLOAT (pr) = 0; return; } count = 0; - s = G_STRING (pr, OFS_PARM1); + s = P_STRING (pr, 1); while (*s) { if (*s == goal) count++; s++; } - G_FLOAT (pr, OFS_RETURN) = count; + R_FLOAT (pr) = count; } #if (INT_MAX == 2147483647) && (INT_MIN == -2147483648) @@ -610,7 +610,7 @@ PF_sprintf (progs_t *pr) new_format_i, ret; int curarg = 3, out_max = 32, out_size = 0; - format = G_STRING (pr, OFS_PARM0); + format = P_STRING (pr, 0); c = format; out = malloc (out_max); @@ -652,7 +652,7 @@ PF_sprintf (progs_t *pr) c++; } else if (*c == '*') { - fmt_minwidth = G_INT (pr, OFS_PARM0 + curarg); + fmt_minwidth = P_INT (pr, 0 + curarg); curarg += 3; } @@ -668,7 +668,7 @@ PF_sprintf (progs_t *pr) c++; } } else if (*c == '*') { - fmt_precision = G_INT (pr, OFS_PARM0 + curarg); + fmt_precision = P_INT (pr, 0 + curarg); curarg += 3; } } @@ -721,7 +721,7 @@ PF_sprintf (progs_t *pr) case 'i': while ((ret = snprintf (&out[out_size], out_max - out_size, new_format, - G_INT (pr, OFS_PARM0 + curarg))) + P_INT (pr, 0 + curarg))) >= out_max - out_size) { char *o; out_max *= 2; @@ -736,7 +736,7 @@ PF_sprintf (progs_t *pr) case 'f': while ((ret = snprintf (&out[out_size], out_max - out_size, new_format, - G_FLOAT (pr, OFS_PARM0 + curarg))) + P_FLOAT (pr, 0 + curarg))) >= out_max - out_size) { char *o; out_max *= 2; @@ -755,7 +755,7 @@ PF_sprintf (progs_t *pr) goto maxargs; while ((ret = snprintf (&out[out_size], out_max - out_size, new_format, - G_FLOAT (pr, OFS_PARM0 + + P_FLOAT (pr, 0 + curarg))) >= out_max - out_size) { char *o; @@ -776,7 +776,7 @@ PF_sprintf (progs_t *pr) char *s; if (curarg > MAX_ARG) goto maxargs; - s = G_STRING (pr, OFS_PARM0 + curarg); + s = P_STRING (pr, 0 + curarg); while ((ret = snprintf (&out[out_size], out_max - out_size, "%s", s)) >= out_max - out_size) { diff --git a/nq/source/pr_cmds.c b/nq/source/pr_cmds.c index a73d1d184..74acc3346 100644 --- a/nq/source/pr_cmds.c +++ b/nq/source/pr_cmds.c @@ -114,7 +114,7 @@ PF_objerror (progs_t *pr) void PF_makevectors (progs_t *pr) { - AngleVectors (G_VECTOR (pr, OFS_PARM0), *sv_globals.v_forward, + AngleVectors (P_VECTOR (pr, 0), *sv_globals.v_forward, *sv_globals.v_right, *sv_globals.v_up); } @@ -131,8 +131,8 @@ PF_setorigin (progs_t *pr) edict_t *e; float *org; - e = G_EDICT (pr, OFS_PARM0); - org = G_VECTOR (pr, OFS_PARM1); + e = P_EDICT (pr, 0); + org = P_VECTOR (pr, 1); VectorCopy (org, SVvector (e, origin)); SV_LinkEdict (e, false); } @@ -222,9 +222,9 @@ PF_setsize (progs_t *pr) edict_t *e; float *min, *max; - e = G_EDICT (pr, OFS_PARM0); - min = G_VECTOR (pr, OFS_PARM1); - max = G_VECTOR (pr, OFS_PARM2); + e = P_EDICT (pr, 0); + min = P_VECTOR (pr, 1); + max = P_VECTOR (pr, 2); SetMinMaxSize (pr, e, min, max, false); } @@ -242,8 +242,8 @@ PF_setmodel (progs_t *pr) model_t *mod; int i; - e = G_EDICT (pr, OFS_PARM0); - m = G_STRING (pr, OFS_PARM1); + e = P_EDICT (pr, 0); + m = P_STRING (pr, 1); // check to see if model was properly precached for (i = 0, check = sv.model_precache; *check; i++, check++) @@ -295,7 +295,7 @@ PF_sprint (progs_t *pr) client_t *client; int entnum; - entnum = G_EDICTNUM (pr, OFS_PARM0); + entnum = P_EDICTNUM (pr, 0); s = PF_VarString (pr, 1); if (entnum < 1 || entnum > svs.maxclients) { @@ -324,7 +324,7 @@ PF_centerprint (progs_t *pr) client_t *client; int entnum; - entnum = G_EDICTNUM (pr, OFS_PARM0); + entnum = P_EDICTNUM (pr, 0); s = PF_VarString (pr, 1); if (entnum < 1 || entnum > svs.maxclients) { @@ -351,10 +351,10 @@ PF_particle (progs_t *pr) float color; float count; - org = G_VECTOR (pr, OFS_PARM0); - dir = G_VECTOR (pr, OFS_PARM1); - color = G_FLOAT (pr, OFS_PARM2); - count = G_FLOAT (pr, OFS_PARM3); + org = P_VECTOR (pr, 0); + dir = P_VECTOR (pr, 1); + color = P_FLOAT (pr, 2); + count = P_FLOAT (pr, 3); SV_StartParticle (org, dir, color, count); } @@ -371,10 +371,10 @@ PF_ambientsound (progs_t *pr) float vol, attenuation; int soundnum; - pos = G_VECTOR (pr, OFS_PARM0); - samp = G_STRING (pr, OFS_PARM1); - vol = G_FLOAT (pr, OFS_PARM2); - attenuation = G_FLOAT (pr, OFS_PARM3); + pos = P_VECTOR (pr, 0); + samp = P_STRING (pr, 1); + vol = P_FLOAT (pr, 2); + attenuation = P_FLOAT (pr, 3); // check to see if samp was properly precached for (soundnum = 0, check = sv.sound_precache; *check; check++, soundnum++) @@ -416,11 +416,11 @@ PF_sound (progs_t *pr) int volume; float attenuation; - entity = G_EDICT (pr, OFS_PARM0); - channel = G_FLOAT (pr, OFS_PARM1); - sample = G_STRING (pr, OFS_PARM2); - volume = G_FLOAT (pr, OFS_PARM3) * 255; - attenuation = G_FLOAT (pr, OFS_PARM4); + entity = P_EDICT (pr, 0); + channel = P_FLOAT (pr, 1); + sample = P_STRING (pr, 2); + volume = P_FLOAT (pr, 3) * 255; + attenuation = P_FLOAT (pr, 4); if (volume < 0 || volume > 255) Sys_Error ("SV_StartSound: volume = %i", volume); @@ -452,10 +452,10 @@ PF_traceline (progs_t *pr) int nomonsters; edict_t *ent; - v1 = G_VECTOR (pr, OFS_PARM0); - v2 = G_VECTOR (pr, OFS_PARM1); - nomonsters = G_FLOAT (pr, OFS_PARM2); - ent = G_EDICT (pr, OFS_PARM3); + v1 = P_VECTOR (pr, 0); + v2 = P_VECTOR (pr, 1); + nomonsters = P_FLOAT (pr, 2); + ent = P_EDICT (pr, 3); trace = SV_Move (v1, vec3_origin, vec3_origin, v2, nomonsters, ent); @@ -607,10 +607,10 @@ PF_stuffcmd (progs_t *pr) const char *str; client_t *old; - entnum = G_EDICTNUM (pr, OFS_PARM0); + entnum = P_EDICTNUM (pr, 0); if (entnum < 1 || entnum > svs.maxclients) PR_RunError (pr, "Parm 0 not a client"); - str = G_STRING (pr, OFS_PARM1); + str = P_STRING (pr, 1); old = host_client; host_client = &svs.clients[entnum - 1]; @@ -630,7 +630,7 @@ PF_localcmd (progs_t *pr) { const char *str; - str = G_STRING (pr, OFS_PARM0); + str = P_STRING (pr, 0); Cbuf_AddText (str); } @@ -652,8 +652,8 @@ PF_findradius (progs_t *pr) chain = (edict_t *) sv.edicts; - org = G_VECTOR (pr, OFS_PARM0); - rad = G_FLOAT (pr, OFS_PARM1); + org = P_VECTOR (pr, 0); + rad = P_FLOAT (pr, 1); ent = NEXT_EDICT (pr, sv.edicts); for (i = 1; i < sv.num_edicts; i++, ent = NEXT_EDICT (pr, ent)) { @@ -690,7 +690,7 @@ PF_Remove (progs_t *pr) { edict_t *ed; - ed = G_EDICT (pr, OFS_PARM0); + ed = P_EDICT (pr, 0); ED_Free (pr, ed); } @@ -708,7 +708,7 @@ PF_precache_file (progs_t *pr) // // // files with qcc, it does nothing - G_INT (pr, OFS_RETURN) = G_INT (pr, OFS_PARM0); + R_INT (pr) = P_INT (pr, 0); } void @@ -721,8 +721,8 @@ PF_precache_sound (progs_t *pr) PR_RunError (pr, "PF_Precache_*: Precache can only be done in spawn functions"); - s = G_STRING (pr, OFS_PARM0); - G_INT (pr, OFS_RETURN) = G_INT (pr, OFS_PARM0); + s = P_STRING (pr, 0); + R_INT (pr) = P_INT (pr, 0); PR_CheckEmptyString (pr, s); for (i = 0; i < MAX_SOUNDS; i++) { @@ -746,8 +746,8 @@ PF_precache_model (progs_t *pr) PR_RunError (pr, "PF_Precache_*: Precache can only be done in spawn functions"); - s = G_STRING (pr, OFS_PARM0); - G_INT (pr, OFS_RETURN) = G_INT (pr, OFS_PARM0); + s = P_STRING (pr, 0); + R_INT (pr) = P_INT (pr, 0); PR_CheckEmptyString (pr, s); for (i = 0; i < MAX_MODELS; i++) { @@ -778,11 +778,11 @@ PF_walkmove (progs_t *pr) int oldself; ent = PROG_TO_EDICT (pr, *sv_globals.self); - yaw = G_FLOAT (pr, OFS_PARM0); - dist = G_FLOAT (pr, OFS_PARM1); + yaw = P_FLOAT (pr, 0); + dist = P_FLOAT (pr, 1); if (!((int) SVfloat (ent, flags) & (FL_ONGROUND | FL_FLY | FL_SWIM))) { - G_FLOAT (pr, OFS_RETURN) = 0; + R_FLOAT (pr) = 0; return; } @@ -796,7 +796,7 @@ PF_walkmove (progs_t *pr) oldf = pr->pr_xfunction; oldself = *sv_globals.self; - G_FLOAT (pr, OFS_RETURN) = SV_movestep (ent, move, true); + R_FLOAT (pr) = SV_movestep (ent, move, true); // restore program state @@ -826,13 +826,13 @@ PF_droptofloor (progs_t *pr) SVvector (ent, maxs), end, false, ent); if (trace.fraction == 1 || trace.allsolid) { - G_FLOAT (pr, OFS_RETURN) = 0; + R_FLOAT (pr) = 0; } else { VectorCopy (trace.endpos, SVvector (ent, origin)); SV_LinkEdict (ent, false); SVfloat (ent, flags) = (int) SVfloat (ent, flags) | FL_ONGROUND; SVentity (ent, groundentity) = EDICT_TO_PROG (pr, trace.ent); - G_FLOAT (pr, OFS_RETURN) = 1; + R_FLOAT (pr) = 1; } } @@ -849,8 +849,8 @@ PF_lightstyle (progs_t *pr) client_t *client; int j; - style = G_FLOAT (pr, OFS_PARM0); - val = G_STRING (pr, OFS_PARM1); + style = P_FLOAT (pr, 0); + val = P_STRING (pr, 1); // change the string in sv sv.lightstyles[style] = val; @@ -875,9 +875,9 @@ PF_checkbottom (progs_t *pr) { edict_t *ent; - ent = G_EDICT (pr, OFS_PARM0); + ent = P_EDICT (pr, 0); - G_FLOAT (pr, OFS_RETURN) = SV_CheckBottom (ent); + R_FLOAT (pr) = SV_CheckBottom (ent); } /* @@ -888,9 +888,9 @@ PF_pointcontents (progs_t *pr) { float *v; - v = G_VECTOR (pr, OFS_PARM0); + v = P_VECTOR (pr, 0); - G_FLOAT (pr, OFS_RETURN) = SV_PointContents (v); + R_FLOAT (pr) = SV_PointContents (v); } /* @@ -910,8 +910,8 @@ PF_aim (progs_t *pr) float dist, bestdist; float speed; - ent = G_EDICT (pr, OFS_PARM0); - speed = G_FLOAT (pr, OFS_PARM1); + ent = P_EDICT (pr, 0); + speed = P_FLOAT (pr, 1); VectorCopy (SVvector (ent, origin), start); start[2] += 20; @@ -923,7 +923,7 @@ PF_aim (progs_t *pr) if (tr.ent && SVfloat (tr.ent, takedamage) == DAMAGE_AIM && (!teamplay->int_val || SVfloat (ent, team) <= 0 || SVfloat (ent, team) != SVfloat (tr.ent, team))) { - VectorCopy (*sv_globals.v_forward, G_VECTOR (pr, OFS_RETURN)); + VectorCopy (*sv_globals.v_forward, R_VECTOR (pr)); return; } // try all possible entities @@ -961,9 +961,9 @@ PF_aim (progs_t *pr) VectorScale (*sv_globals.v_forward, dist, end); end[2] = dir[2]; VectorNormalize (end); - VectorCopy (end, G_VECTOR (pr, OFS_RETURN)); + VectorCopy (end, R_VECTOR (pr)); } else { - VectorCopy (bestdir, G_VECTOR (pr, OFS_RETURN)); + VectorCopy (bestdir, R_VECTOR (pr)); } } @@ -1025,7 +1025,7 @@ WriteDest (progs_t *pr) int dest; edict_t *ent; - dest = G_FLOAT (pr, OFS_PARM0); + dest = P_FLOAT (pr, 0); switch (dest) { case MSG_BROADCAST: return &sv.datagram; @@ -1054,50 +1054,50 @@ WriteDest (progs_t *pr) void PF_WriteByte (progs_t *pr) { - MSG_WriteByte (WriteDest (pr), G_FLOAT (pr, OFS_PARM1)); + MSG_WriteByte (WriteDest (pr), P_FLOAT (pr, 1)); } void PF_WriteChar (progs_t *pr) { - MSG_WriteByte (WriteDest (pr), G_FLOAT (pr, OFS_PARM1)); + MSG_WriteByte (WriteDest (pr), P_FLOAT (pr, 1)); } void PF_WriteShort (progs_t *pr) { - MSG_WriteShort (WriteDest (pr), G_FLOAT (pr, OFS_PARM1)); + MSG_WriteShort (WriteDest (pr), P_FLOAT (pr, 1)); } void PF_WriteLong (progs_t *pr) { - MSG_WriteLong (WriteDest (pr), G_FLOAT (pr, OFS_PARM1)); + MSG_WriteLong (WriteDest (pr), P_FLOAT (pr, 1)); } void PF_WriteAngle (progs_t *pr) { - MSG_WriteAngle (WriteDest (pr), G_FLOAT (pr, OFS_PARM1)); + MSG_WriteAngle (WriteDest (pr), P_FLOAT (pr, 1)); } void PF_WriteCoord (progs_t *pr) { - MSG_WriteCoord (WriteDest (pr), G_FLOAT (pr, OFS_PARM1)); + MSG_WriteCoord (WriteDest (pr), P_FLOAT (pr, 1)); } void PF_WriteString (progs_t *pr) { - MSG_WriteString (WriteDest (pr), G_STRING (pr, OFS_PARM1)); + MSG_WriteString (WriteDest (pr), P_STRING (pr, 1)); } void PF_WriteEntity (progs_t *pr) { - MSG_WriteShort (WriteDest (pr), G_EDICTNUM (pr, OFS_PARM1)); + MSG_WriteShort (WriteDest (pr), P_EDICTNUM (pr, 1)); } //============================================================================= @@ -1107,7 +1107,7 @@ PF_makestatic (progs_t *pr) { edict_t *ent; - ent = G_EDICT (pr, OFS_PARM0); + ent = P_EDICT (pr, 0); MSG_WriteByte (&sv.signon, svc_spawnstatic); @@ -1141,7 +1141,7 @@ PF_setspawnparms (progs_t *pr) int i; client_t *client; - ent = G_EDICT (pr, OFS_PARM0); + ent = P_EDICT (pr, 0); i = NUM_FOR_EDICT (pr, ent); if (i < 1 || i > svs.maxclients) PR_RunError (pr, "Entity is not a client"); @@ -1166,7 +1166,7 @@ PF_changelevel (progs_t *pr) return; svs.changelevel_issued = true; - s = G_STRING (pr, OFS_PARM0); + s = P_STRING (pr, 0); Cbuf_AddText (va ("changelevel %s\n", s)); } @@ -1177,31 +1177,31 @@ clip_hull_t *pf_hull_list[MAX_PF_HULLS]; static void PF_hullpointcontents (progs_t *pr) { - edict_t *edict = G_EDICT (pr, OFS_PARM0); - float *mins = G_VECTOR (pr, OFS_PARM1); - float *maxs = G_VECTOR (pr, OFS_PARM2); - float *point = G_VECTOR (pr, OFS_PARM3); + edict_t *edict = P_EDICT (pr, 0); + float *mins = P_VECTOR (pr, 1); + float *maxs = P_VECTOR (pr, 2); + float *point = P_VECTOR (pr, 3); hull_t *hull; vec3_t offset; hull = SV_HullForEntity (edict, mins, maxs, offset); VectorSubtract (point, offset, offset); - G_INT (pr, OFS_RETURN) = SV_HullPointContents (hull, 0, offset); + R_INT (pr) = SV_HullPointContents (hull, 0, offset); } static void PF_getboxbounds (progs_t *pr) { - int h = G_INT (pr, OFS_PARM0) - 1; + int h = P_INT (pr, 0) - 1; clip_hull_t *ch; if (h < 0 || h > MAX_PF_HULLS - 1 || !(ch = pf_hull_list[h])) PR_RunError (pr, "PF_freeboxhull: invalid box hull handle\n"); - if (G_INT (pr, OFS_PARM1)) { - VectorCopy (ch->maxs, G_VECTOR (pr, OFS_RETURN)); + if (P_INT (pr, 1)) { + VectorCopy (ch->maxs, R_VECTOR (pr)); } else { - VectorCopy (ch->mins, G_VECTOR (pr, OFS_RETURN)); + VectorCopy (ch->mins, R_VECTOR (pr)); } } @@ -1220,19 +1220,19 @@ PF_getboxhull (progs_t *pr) if (ch) { pf_hull_list[i] = ch; - G_INT (pr, OFS_RETURN) = i + 1; + R_INT (pr) = i + 1; for (i = 0; i < MAX_MAP_HULLS; i++) SV_InitHull (ch->hulls[i], ch->hulls[i]->clipnodes, ch->hulls[i]->planes); } else { - G_INT (pr, OFS_RETURN) = 0; + R_INT (pr) = 0; } } static void PF_freeboxhull (progs_t *pr) { - int h = G_INT (pr, OFS_PARM0) - 1; + int h = P_INT (pr, 0) - 1; clip_hull_t *ch; if (h < 0 || h > MAX_PF_HULLS - 1 || !(ch = pf_hull_list[h])) @@ -1261,14 +1261,14 @@ calc_dist (vec3_t p, vec3_t n, vec3_t *offsets) static void PF_rotate_bbox (progs_t *pr) { - int h = G_INT (pr, OFS_PARM0) - 1; + int h = P_INT (pr, 0) - 1; float *dir[3] = { - G_VECTOR (pr, OFS_PARM1), - G_VECTOR (pr, OFS_PARM2), - G_VECTOR (pr, OFS_PARM3), + P_VECTOR (pr, 1), + P_VECTOR (pr, 2), + P_VECTOR (pr, 3), }; - float *mi = G_VECTOR (pr, OFS_PARM4); - float *ma = G_VECTOR (pr, OFS_PARM5); + float *mi = P_VECTOR (pr, 4); + float *ma = P_VECTOR (pr, 5); vec3_t mins, maxs; float *verts[6] = {maxs, mins, maxs, mins, maxs, mins}; diff --git a/nq/source/sv_move.c b/nq/source/sv_move.c index 52761163e..bb6ecd650 100644 --- a/nq/source/sv_move.c +++ b/nq/source/sv_move.c @@ -355,10 +355,10 @@ SV_MoveToGoal (progs_t *pr) ent = PROG_TO_EDICT (pr, *pr->globals.self); goal = PROG_TO_EDICT (pr, SVentity (ent, goalentity)); - dist = G_FLOAT (pr, OFS_PARM0); + dist = P_FLOAT (pr, 0); if (!((int) SVfloat (ent, flags) & (FL_ONGROUND | FL_FLY | FL_SWIM))) { - G_FLOAT (pr, OFS_RETURN) = 0; + R_FLOAT (pr) = 0; return; } // if the next step hits the enemy, return immediately diff --git a/qw/source/sv_move.c b/qw/source/sv_move.c index 52761163e..bb6ecd650 100644 --- a/qw/source/sv_move.c +++ b/qw/source/sv_move.c @@ -355,10 +355,10 @@ SV_MoveToGoal (progs_t *pr) ent = PROG_TO_EDICT (pr, *pr->globals.self); goal = PROG_TO_EDICT (pr, SVentity (ent, goalentity)); - dist = G_FLOAT (pr, OFS_PARM0); + dist = P_FLOAT (pr, 0); if (!((int) SVfloat (ent, flags) & (FL_ONGROUND | FL_FLY | FL_SWIM))) { - G_FLOAT (pr, OFS_RETURN) = 0; + R_FLOAT (pr) = 0; return; } // if the next step hits the enemy, return immediately diff --git a/qw/source/sv_pr_cmds.c b/qw/source/sv_pr_cmds.c index 9fc0bba65..f811c6f94 100644 --- a/qw/source/sv_pr_cmds.c +++ b/qw/source/sv_pr_cmds.c @@ -110,7 +110,7 @@ PF_objerror (progs_t *pr) void PF_makevectors (progs_t *pr) { - AngleVectors (G_VECTOR (pr, OFS_PARM0), *sv_globals.v_forward, + AngleVectors (P_VECTOR (pr, 0), *sv_globals.v_forward, *sv_globals.v_right, *sv_globals.v_up); } @@ -131,8 +131,8 @@ PF_setorigin (progs_t *pr) edict_t *e; float *org; - e = G_EDICT (pr, OFS_PARM0); - org = G_VECTOR (pr, OFS_PARM1); + e = P_EDICT (pr, 0); + org = P_VECTOR (pr, 1); VectorCopy (org, SVvector (e, origin)); SV_LinkEdict (e, false); } @@ -150,9 +150,9 @@ PF_setsize (progs_t *pr) edict_t *e; float *min, *max; - e = G_EDICT (pr, OFS_PARM0); - min = G_VECTOR (pr, OFS_PARM1); - max = G_VECTOR (pr, OFS_PARM2); + e = P_EDICT (pr, 0); + min = P_VECTOR (pr, 1); + max = P_VECTOR (pr, 2); VectorCopy (min, SVvector (e, mins)); VectorCopy (max, SVvector (e, maxs)); VectorSubtract (max, min, SVvector (e, size)); @@ -173,8 +173,8 @@ PF_setmodel (progs_t *pr) int i; model_t *mod; - e = G_EDICT (pr, OFS_PARM0); - m = G_STRING (pr, OFS_PARM1); + e = P_EDICT (pr, 0); + m = P_STRING (pr, 1); // check to see if model was properly precached for (i = 0, check = sv.model_precache; *check; i++, check++) @@ -210,7 +210,7 @@ PF_bprint (progs_t *pr) const char *s; int level; - level = G_FLOAT (pr, OFS_PARM0); + level = P_FLOAT (pr, 0); s = PF_VarString (pr, 1); SV_BroadcastPrintf (level, "%s", s); @@ -230,8 +230,8 @@ PF_sprint (progs_t *pr) client_t *client; int entnum, level; - entnum = G_EDICTNUM (pr, OFS_PARM0); - level = G_FLOAT (pr, OFS_PARM1); + entnum = P_EDICTNUM (pr, 0); + level = P_FLOAT (pr, 1); s = PF_VarString (pr, 2); @@ -259,7 +259,7 @@ PF_centerprint (progs_t *pr) client_t *cl; int entnum; - entnum = G_EDICTNUM (pr, OFS_PARM0); + entnum = P_EDICTNUM (pr, 0); s = PF_VarString (pr, 1); if (entnum < 1 || entnum > MAX_CLIENTS) { @@ -285,10 +285,10 @@ PF_ambientsound (progs_t *pr) float vol, attenuation; int soundnum; - pos = G_VECTOR (pr, OFS_PARM0); - samp = G_STRING (pr, OFS_PARM1); - vol = G_FLOAT (pr, OFS_PARM2); - attenuation = G_FLOAT (pr, OFS_PARM3); + pos = P_VECTOR (pr, 0); + samp = P_STRING (pr, 1); + vol = P_FLOAT (pr, 2); + attenuation = P_FLOAT (pr, 3); // check to see if samp was properly precached for (soundnum = 0, check = sv.sound_precache; *check; check++, soundnum++) @@ -331,11 +331,11 @@ PF_sound (progs_t *pr) float attenuation; int channel, volume; - entity = G_EDICT (pr, OFS_PARM0); - channel = G_FLOAT (pr, OFS_PARM1); - sample = G_STRING (pr, OFS_PARM2); - volume = G_FLOAT (pr, OFS_PARM3) * 255; - attenuation = G_FLOAT (pr, OFS_PARM4); + entity = P_EDICT (pr, 0); + channel = P_FLOAT (pr, 1); + sample = P_STRING (pr, 2); + volume = P_FLOAT (pr, 3) * 255; + attenuation = P_FLOAT (pr, 4); SV_StartSound (entity, channel, sample, volume, attenuation); } @@ -357,10 +357,10 @@ PF_traceline (progs_t *pr) int nomonsters; trace_t trace; - v1 = G_VECTOR (pr, OFS_PARM0); - v2 = G_VECTOR (pr, OFS_PARM1); - nomonsters = G_FLOAT (pr, OFS_PARM2); - ent = G_EDICT (pr, OFS_PARM3); + v1 = P_VECTOR (pr, 0); + v2 = P_VECTOR (pr, 1); + nomonsters = P_FLOAT (pr, 2); + ent = P_EDICT (pr, 3); trace = SV_Move (v1, vec3_origin, vec3_origin, v2, nomonsters, ent); @@ -392,12 +392,12 @@ PF_checkmove (progs_t *pr) int type; trace_t trace; - start = G_VECTOR (pr, OFS_PARM0); - mins = G_VECTOR (pr, OFS_PARM1); - maxs = G_VECTOR (pr, OFS_PARM2); - end = G_VECTOR (pr, OFS_PARM3); - type = G_FLOAT (pr, OFS_PARM4); - ent = G_EDICT (pr, OFS_PARM5); + start = P_VECTOR (pr, 0); + mins = P_VECTOR (pr, 1); + maxs = P_VECTOR (pr, 2); + end = P_VECTOR (pr, 3); + type = P_FLOAT (pr, 4); + ent = P_EDICT (pr, 5); trace = SV_Move (start, mins, maxs, end, type, ent); @@ -542,10 +542,10 @@ PF_stuffcmd (progs_t *pr) client_t *cl; int entnum; - entnum = G_EDICTNUM (pr, OFS_PARM0); + entnum = P_EDICTNUM (pr, 0); if (entnum < 1 || entnum > MAX_CLIENTS) PR_RunError (pr, "Parm 0 not a client"); - str = G_STRING (pr, OFS_PARM1); + str = P_STRING (pr, 1); cl = &svs.clients[entnum - 1]; @@ -585,7 +585,7 @@ PF_localcmd (progs_t *pr) { const char *str; - str = G_STRING (pr, OFS_PARM0); + str = P_STRING (pr, 0); Cbuf_AddText (str); } @@ -607,8 +607,8 @@ PF_findradius (progs_t *pr) chain = (edict_t *) sv.edicts; - VectorScale (G_VECTOR (pr, OFS_PARM0), 2, org); - rad = G_FLOAT (pr, OFS_PARM1); + VectorScale (P_VECTOR (pr, 0), 2, org); + rad = P_FLOAT (pr, 1); // * 4 because the * 0.5 was removed from the emins-emaxs average rad *= 4 * rad; // Square early, sqrt never @@ -650,7 +650,7 @@ PF_Remove (progs_t *pr) { edict_t *ed; - ed = G_EDICT (pr, OFS_PARM0); + ed = P_EDICT (pr, 0); if (ed->free && pr_double_remove->int_val) { if (pr_double_remove->int_val == 1) { PR_DumpState (pr); @@ -672,7 +672,7 @@ void PF_precache_file (progs_t *pr) { // precache_file is only used to copy // files with qcc, it does nothing - G_INT (pr, OFS_RETURN) = G_INT (pr, OFS_PARM0); + R_INT (pr) = P_INT (pr, 0); } void @@ -685,8 +685,8 @@ PF_precache_sound (progs_t *pr) PR_RunError (pr, "PF_Precache_*: Precache can only be done in spawn " "functions"); - s = G_STRING (pr, OFS_PARM0); - G_INT (pr, OFS_RETURN) = G_INT (pr, OFS_PARM0); + s = P_STRING (pr, 0); + R_INT (pr) = P_INT (pr, 0); PR_CheckEmptyString (pr, s); for (i = 0; i < MAX_SOUNDS; i++) { @@ -714,8 +714,8 @@ PF_precache_model (progs_t *pr) (pr, "PF_Precache_model: Precache can only be done in spawn " "functions"); - s = G_STRING (pr, OFS_PARM0); - G_INT (pr, OFS_RETURN) = G_INT (pr, OFS_PARM0); + s = P_STRING (pr, 0); + R_INT (pr) = P_INT (pr, 0); PR_CheckEmptyString (pr, s); for (i = 0; i < MAX_MODELS; i++) { @@ -748,11 +748,11 @@ PF_walkmove (progs_t *pr) vec3_t move; ent = PROG_TO_EDICT (pr, *sv_globals.self); - yaw = G_FLOAT (pr, OFS_PARM0); - dist = G_FLOAT (pr, OFS_PARM1); + yaw = P_FLOAT (pr, 0); + dist = P_FLOAT (pr, 1); if (!((int) SVfloat (ent, flags) & (FL_ONGROUND | FL_FLY | FL_SWIM))) { - G_FLOAT (pr, OFS_RETURN) = 0; + R_FLOAT (pr) = 0; return; } @@ -766,7 +766,7 @@ PF_walkmove (progs_t *pr) oldf = pr->pr_xfunction; oldself = *sv_globals.self; - G_FLOAT (pr, OFS_RETURN) = SV_movestep (ent, move, true); + R_FLOAT (pr) = SV_movestep (ent, move, true); // restore program state pr->pr_xfunction = oldf; @@ -794,13 +794,13 @@ PF_droptofloor (progs_t *pr) SVvector (ent, maxs), end, false, ent); if (trace.fraction == 1 || trace.allsolid) - G_FLOAT (pr, OFS_RETURN) = 0; + R_FLOAT (pr) = 0; else { VectorCopy (trace.endpos, SVvector (ent, origin)); SV_LinkEdict (ent, false); SVfloat (ent, flags) = (int) SVfloat (ent, flags) | FL_ONGROUND; SVentity (ent, groundentity) = EDICT_TO_PROG (pr, trace.ent); - G_FLOAT (pr, OFS_RETURN) = 1; + R_FLOAT (pr) = 1; } } @@ -816,8 +816,8 @@ PF_lightstyle (progs_t *pr) client_t *client; int style, j; - style = G_FLOAT (pr, OFS_PARM0); - val = G_STRING (pr, OFS_PARM1); + style = P_FLOAT (pr, 0); + val = P_STRING (pr, 1); // change the string in sv sv.lightstyles[style] = val; @@ -843,9 +843,9 @@ PF_checkbottom (progs_t *pr) { edict_t *ent; - ent = G_EDICT (pr, OFS_PARM0); + ent = P_EDICT (pr, 0); - G_FLOAT (pr, OFS_RETURN) = SV_CheckBottom (ent); + R_FLOAT (pr) = SV_CheckBottom (ent); } void @@ -853,9 +853,9 @@ PF_pointcontents (progs_t *pr) { float *v; - v = G_VECTOR (pr, OFS_PARM0); + v = P_VECTOR (pr, 0); - G_FLOAT (pr, OFS_RETURN) = SV_PointContents (v); + R_FLOAT (pr) = SV_PointContents (v); } cvar_t *sv_aim; @@ -878,22 +878,22 @@ PF_aim (progs_t *pr) const char *noaim; if (sv_aim->value >= 1.0) { - VectorCopy (*sv_globals.v_forward, G_VECTOR (pr, OFS_RETURN)); + VectorCopy (*sv_globals.v_forward, R_VECTOR (pr)); return; } - ent = G_EDICT (pr, OFS_PARM0); + ent = P_EDICT (pr, 0); // noaim option i = NUM_FOR_EDICT (pr, ent); if (i > 0 && i < MAX_CLIENTS) { noaim = Info_ValueForKey (svs.clients[i - 1].userinfo, "noaim"); if (atoi (noaim) > 0) { - VectorCopy (*sv_globals.v_forward, G_VECTOR (pr, OFS_RETURN)); + VectorCopy (*sv_globals.v_forward, R_VECTOR (pr)); return; } } - speed = G_FLOAT (pr, OFS_PARM1); + speed = P_FLOAT (pr, 1); VectorCopy (SVvector (ent, origin), start); start[2] += 20; @@ -905,7 +905,7 @@ PF_aim (progs_t *pr) if (tr.ent && SVfloat (tr.ent, takedamage) == DAMAGE_AIM && (!teamplay->int_val || SVfloat (ent, team) <= 0 || SVfloat (ent, team) != SVfloat (tr.ent, team))) { - VectorCopy (*sv_globals.v_forward, G_VECTOR (pr, OFS_RETURN)); + VectorCopy (*sv_globals.v_forward, R_VECTOR (pr)); return; } @@ -945,9 +945,9 @@ PF_aim (progs_t *pr) VectorScale (*sv_globals.v_forward, dist, end); end[2] = dir[2]; VectorNormalize (end); - VectorCopy (end, G_VECTOR (pr, OFS_RETURN)); + VectorCopy (end, R_VECTOR (pr)); } else { - VectorCopy (bestdir, G_VECTOR (pr, OFS_RETURN)); + VectorCopy (bestdir, R_VECTOR (pr)); } } @@ -1001,7 +1001,7 @@ WriteDest (progs_t *pr) { int dest; - dest = G_FLOAT (pr, OFS_PARM0); + dest = P_FLOAT (pr, 0); switch (dest) { case MSG_BROADCAST: return &sv.datagram; @@ -1052,97 +1052,97 @@ Write_GetClient (progs_t *pr) void PF_WriteByte (progs_t *pr) { - if (G_FLOAT (pr, OFS_PARM0) == MSG_ONE) { + if (P_FLOAT (pr, 0) == MSG_ONE) { client_t *cl = Write_GetClient (pr); ClientReliableCheckBlock (cl, 1); - ClientReliableWrite_Byte (cl, G_FLOAT (pr, OFS_PARM1)); + ClientReliableWrite_Byte (cl, P_FLOAT (pr, 1)); } else - MSG_WriteByte (WriteDest (pr), G_FLOAT (pr, OFS_PARM1)); + MSG_WriteByte (WriteDest (pr), P_FLOAT (pr, 1)); } void PF_WriteChar (progs_t *pr) { - if (G_FLOAT (pr, OFS_PARM0) == MSG_ONE) { + if (P_FLOAT (pr, 0) == MSG_ONE) { client_t *cl = Write_GetClient (pr); ClientReliableCheckBlock (cl, 1); - ClientReliableWrite_Char (cl, G_FLOAT (pr, OFS_PARM1)); + ClientReliableWrite_Char (cl, P_FLOAT (pr, 1)); } else - MSG_WriteByte (WriteDest (pr), G_FLOAT (pr, OFS_PARM1)); + MSG_WriteByte (WriteDest (pr), P_FLOAT (pr, 1)); } void PF_WriteShort (progs_t *pr) { - if (G_FLOAT (pr, OFS_PARM0) == MSG_ONE) { + if (P_FLOAT (pr, 0) == MSG_ONE) { client_t *cl = Write_GetClient (pr); ClientReliableCheckBlock (cl, 2); - ClientReliableWrite_Short (cl, G_FLOAT (pr, OFS_PARM1)); + ClientReliableWrite_Short (cl, P_FLOAT (pr, 1)); } else - MSG_WriteShort (WriteDest (pr), G_FLOAT (pr, OFS_PARM1)); + MSG_WriteShort (WriteDest (pr), P_FLOAT (pr, 1)); } void PF_WriteLong (progs_t *pr) { - if (G_FLOAT (pr, OFS_PARM0) == MSG_ONE) { + if (P_FLOAT (pr, 0) == MSG_ONE) { client_t *cl = Write_GetClient (pr); ClientReliableCheckBlock (cl, 4); - ClientReliableWrite_Long (cl, G_FLOAT (pr, OFS_PARM1)); + ClientReliableWrite_Long (cl, P_FLOAT (pr, 1)); } else - MSG_WriteLong (WriteDest (pr), G_FLOAT (pr, OFS_PARM1)); + MSG_WriteLong (WriteDest (pr), P_FLOAT (pr, 1)); } void PF_WriteAngle (progs_t *pr) { - if (G_FLOAT (pr, OFS_PARM0) == MSG_ONE) { + if (P_FLOAT (pr, 0) == MSG_ONE) { client_t *cl = Write_GetClient (pr); ClientReliableCheckBlock (cl, 1); - ClientReliableWrite_Angle (cl, G_FLOAT (pr, OFS_PARM1)); + ClientReliableWrite_Angle (cl, P_FLOAT (pr, 1)); } else - MSG_WriteAngle (WriteDest (pr), G_FLOAT (pr, OFS_PARM1)); + MSG_WriteAngle (WriteDest (pr), P_FLOAT (pr, 1)); } void PF_WriteCoord (progs_t *pr) { - if (G_FLOAT (pr, OFS_PARM0) == MSG_ONE) { + if (P_FLOAT (pr, 0) == MSG_ONE) { client_t *cl = Write_GetClient (pr); ClientReliableCheckBlock (cl, 2); - ClientReliableWrite_Coord (cl, G_FLOAT (pr, OFS_PARM1)); + ClientReliableWrite_Coord (cl, P_FLOAT (pr, 1)); } else - MSG_WriteCoord (WriteDest (pr), G_FLOAT (pr, OFS_PARM1)); + MSG_WriteCoord (WriteDest (pr), P_FLOAT (pr, 1)); } void PF_WriteString (progs_t *pr) { - if (G_FLOAT (pr, OFS_PARM0) == MSG_ONE) { + if (P_FLOAT (pr, 0) == MSG_ONE) { client_t *cl = Write_GetClient (pr); - ClientReliableCheckBlock (cl, 1 + strlen (G_STRING (pr, OFS_PARM1))); - ClientReliableWrite_String (cl, G_STRING (pr, OFS_PARM1)); + ClientReliableCheckBlock (cl, 1 + strlen (P_STRING (pr, 1))); + ClientReliableWrite_String (cl, P_STRING (pr, 1)); } else - MSG_WriteString (WriteDest (pr), G_STRING (pr, OFS_PARM1)); + MSG_WriteString (WriteDest (pr), P_STRING (pr, 1)); } void PF_WriteEntity (progs_t *pr) { - if (G_FLOAT (pr, OFS_PARM0) == MSG_ONE) { + if (P_FLOAT (pr, 0) == MSG_ONE) { client_t *cl = Write_GetClient (pr); ClientReliableCheckBlock (cl, 2); - ClientReliableWrite_Short (cl, G_EDICTNUM (pr, OFS_PARM1)); + ClientReliableWrite_Short (cl, P_EDICTNUM (pr, 1)); } else - MSG_WriteShort (WriteDest (pr), G_EDICTNUM (pr, OFS_PARM1)); + MSG_WriteShort (WriteDest (pr), P_EDICTNUM (pr, 1)); } int SV_ModelIndex (const char *name); @@ -1153,7 +1153,7 @@ PF_makestatic (progs_t *pr) const char *model; edict_t *ent; - ent = G_EDICT (pr, OFS_PARM0); + ent = P_EDICT (pr, 0); MSG_WriteByte (&sv.signon, svc_spawnstatic); @@ -1178,7 +1178,7 @@ PF_setspawnparms (progs_t *pr) edict_t *ent; int i; - ent = G_EDICT (pr, OFS_PARM0); + ent = P_EDICT (pr, 0); i = NUM_FOR_EDICT (pr, ent); if (i < 1 || i > MAX_CLIENTS) PR_RunError (pr, "Entity is not a client"); @@ -1201,7 +1201,7 @@ PF_changelevel (progs_t *pr) return; last_spawncount = svs.spawncount; - s = G_STRING (pr, OFS_PARM0); + s = P_STRING (pr, 0); Cbuf_AddText (va ("map %s\n", s)); } @@ -1217,8 +1217,8 @@ PF_logfrag (progs_t *pr) edict_t *ent1, *ent2; int e1, e2; - ent1 = G_EDICT (pr, OFS_PARM0); - ent2 = G_EDICT (pr, OFS_PARM1); + ent1 = P_EDICT (pr, 0); + ent2 = P_EDICT (pr, 1); e1 = NUM_FOR_EDICT (pr, ent1); e2 = NUM_FOR_EDICT (pr, ent2); @@ -1249,9 +1249,9 @@ PF_infokey (progs_t *pr) edict_t *e; int e1; - e = G_EDICT (pr, OFS_PARM0); + e = P_EDICT (pr, 0); e1 = NUM_FOR_EDICT (pr, e); - key = G_STRING (pr, OFS_PARM1); + key = P_STRING (pr, 1); if (sv_hide_version_info->int_val && (strequal (key, "*qf_version") @@ -1294,8 +1294,8 @@ PF_multicast (progs_t *pr) float *o; int to; - o = G_VECTOR (pr, OFS_PARM0); - to = G_FLOAT (pr, OFS_PARM1); + o = P_VECTOR (pr, 0); + to = P_FLOAT (pr, 1); SV_Multicast (o, to); } @@ -1308,8 +1308,8 @@ PF_multicast (progs_t *pr) void PF_cfopen (progs_t *pr) { - G_FLOAT (pr, OFS_RETURN) = CF_Open (G_STRING (pr, OFS_PARM0), - G_STRING (pr, OFS_PARM1)); + R_FLOAT (pr) = CF_Open (P_STRING (pr, 0), + P_STRING (pr, 1)); } /* @@ -1320,7 +1320,7 @@ PF_cfopen (progs_t *pr) void PF_cfclose (progs_t *pr) { - CF_Close ((int) G_FLOAT (pr, OFS_PARM0)); + CF_Close ((int) P_FLOAT (pr, 0)); } /* @@ -1331,7 +1331,7 @@ PF_cfclose (progs_t *pr) void PF_cfread (progs_t *pr) { - RETURN_STRING (pr, CF_Read((int) G_FLOAT (pr, OFS_PARM0))); + RETURN_STRING (pr, CF_Read((int) P_FLOAT (pr, 0))); } /* @@ -1342,8 +1342,8 @@ PF_cfread (progs_t *pr) void PF_cfwrite (progs_t *pr) { - G_FLOAT (pr, OFS_RETURN) = CF_Write((int) G_FLOAT(pr, OFS_PARM0), - G_STRING (pr, OFS_PARM1)); + R_FLOAT (pr) = CF_Write((int) G_FLOAT(pr, OFS_PARM0), + P_STRING (pr, 1)); } /* @@ -1354,7 +1354,7 @@ PF_cfwrite (progs_t *pr) void PF_cfeof (progs_t *pr) { - G_FLOAT (pr, OFS_RETURN) = CF_EOF ((int) G_FLOAT(pr, OFS_PARM0)); + R_FLOAT (pr) = CF_EOF ((int) G_FLOAT(pr, OFS_PARM0)); } /* @@ -1365,16 +1365,16 @@ PF_cfeof (progs_t *pr) void PF_cfquota (progs_t *pr) { - G_FLOAT (pr, OFS_RETURN) = CF_Quota(); + R_FLOAT (pr) = CF_Quota(); } void PF_setinfokey (progs_t *pr) { - edict_t *edict = G_EDICT (pr, OFS_PARM0); + edict_t *edict = P_EDICT (pr, 0); int e1 = NUM_FOR_EDICT (pr, edict); - const char *key = G_STRING (pr, OFS_PARM1); - const char *value = G_STRING (pr, OFS_PARM2); + const char *key = P_STRING (pr, 1); + const char *value = P_STRING (pr, 2); if (e1 == 0) { if (*value) @@ -1401,7 +1401,7 @@ PF_setinfokey (progs_t *pr) static void PF_testentitypos (progs_t *pr) { - edict_t *ent = G_EDICT (pr, OFS_PARM0); + edict_t *ent = P_EDICT (pr, 0); ent = SV_TestEntityPosition (ent); RETURN_EDICT (pr, ent ? ent : sv.edicts); } @@ -1412,31 +1412,31 @@ clip_hull_t *pf_hull_list[MAX_PF_HULLS]; static void PF_hullpointcontents (progs_t *pr) { - edict_t *edict = G_EDICT (pr, OFS_PARM0); - float *mins = G_VECTOR (pr, OFS_PARM1); - float *maxs = G_VECTOR (pr, OFS_PARM2); - float *point = G_VECTOR (pr, OFS_PARM3); + edict_t *edict = P_EDICT (pr, 0); + float *mins = P_VECTOR (pr, 1); + float *maxs = P_VECTOR (pr, 2); + float *point = P_VECTOR (pr, 3); hull_t *hull; vec3_t offset; hull = SV_HullForEntity (edict, mins, maxs, offset); VectorSubtract (point, offset, offset); - G_INT (pr, OFS_RETURN) = SV_HullPointContents (hull, 0, offset); + R_INT (pr) = SV_HullPointContents (hull, 0, offset); } static void PF_getboxbounds (progs_t *pr) { clip_hull_t *ch; - int h = G_INT (pr, OFS_PARM0) - 1; + int h = P_INT (pr, 0) - 1; if (h < 0 || h > MAX_PF_HULLS - 1 || !(ch = pf_hull_list[h])) PR_RunError (pr, "PF_getboxbounds: invalid box hull handle\n"); - if (G_INT (pr, OFS_PARM1)) { - VectorCopy (ch->maxs, G_VECTOR (pr, OFS_RETURN)); + if (P_INT (pr, 1)) { + VectorCopy (ch->maxs, R_VECTOR (pr)); } else { - VectorCopy (ch->mins, G_VECTOR (pr, OFS_RETURN)); + VectorCopy (ch->mins, R_VECTOR (pr)); } } @@ -1455,19 +1455,19 @@ PF_getboxhull (progs_t *pr) if (ch) { pf_hull_list[i] = ch; - G_INT (pr, OFS_RETURN) = i + 1; + R_INT (pr) = i + 1; for (i = 0; i < MAX_MAP_HULLS; i++) SV_InitHull (ch->hulls[i], ch->hulls[i]->clipnodes, ch->hulls[i]->planes); } else { - G_INT (pr, OFS_RETURN) = 0; + R_INT (pr) = 0; } } static void PF_freeboxhull (progs_t *pr) { - int h = G_INT (pr, OFS_PARM0) - 1; + int h = P_INT (pr, 0) - 1; clip_hull_t *ch; if (h < 0 || h > MAX_PF_HULLS - 1 || !(ch = pf_hull_list[h])) @@ -1498,17 +1498,17 @@ PF_rotate_bbox (progs_t *pr) { clip_hull_t *ch; float l; - float *mi = G_VECTOR (pr, OFS_PARM4); - float *ma = G_VECTOR (pr, OFS_PARM5); + float *mi = P_VECTOR (pr, 4); + float *ma = P_VECTOR (pr, 5); float *dir[3] = { - G_VECTOR (pr, OFS_PARM1), - G_VECTOR (pr, OFS_PARM2), - G_VECTOR (pr, OFS_PARM3), + P_VECTOR (pr, 1), + P_VECTOR (pr, 2), + P_VECTOR (pr, 3), }; hull_t *hull; int i, j; - int h = G_INT (pr, OFS_PARM0) - 1; + int h = P_INT (pr, 0) - 1; vec3_t mins, maxs, d; float *verts[6] = {maxs, mins, maxs, mins, maxs, mins}; @@ -1593,13 +1593,13 @@ PF_sv_cvar (progs_t *pr) { const char *str; - str = G_STRING (pr, OFS_PARM0); + str = P_STRING (pr, 0); if (sv_hide_version_info->int_val && strequal (str, "sv_hide_version_info")) { - G_FLOAT (pr, OFS_RETURN) = 0; + R_FLOAT (pr) = 0; } else { - G_FLOAT (pr, OFS_RETURN) = Cvar_VariableValue (str); + R_FLOAT (pr) = Cvar_VariableValue (str); } } diff --git a/tools/qwaq/builtins.c b/tools/qwaq/builtins.c index 3e69dc980..80804ebf0 100644 --- a/tools/qwaq/builtins.c +++ b/tools/qwaq/builtins.c @@ -60,37 +60,37 @@ bi_GarbageCollect (progs_t *pr) static void bi_errno (progs_t *pr) { - G_INT (pr, OFS_RETURN) = errno; + R_INT (pr) = errno; } static void bi_strerror (progs_t *pr) { - int err = G_INT (pr, OFS_PARM0); + int err = P_INT (pr, 0); RETURN_STRING (pr, strerror (err)); } static void bi_open (progs_t *pr) { - char *path = G_STRING (pr, OFS_PARM0); - int flags = G_INT (pr, OFS_PARM1); - int mode = G_INT (pr, OFS_PARM2); - G_INT (pr, OFS_RETURN) = open (path, flags, mode); + char *path = P_STRING (pr, 0); + int flags = P_INT (pr, 1); + int mode = P_INT (pr, 2); + R_INT (pr) = open (path, flags, mode); } static void bi_close (progs_t *pr) { - int handle = G_INT (pr, OFS_PARM0); - G_INT (pr, OFS_RETURN) = close (handle); + int handle = P_INT (pr, 0); + R_INT (pr) = close (handle); } static void bi_read (progs_t *pr) { - int handle = G_INT (pr, OFS_PARM0); - int count = G_INT (pr, OFS_PARM1); + int handle = P_INT (pr, 0); + int count = P_INT (pr, 1); int res; char *buffer; @@ -106,21 +106,21 @@ bi_read (progs_t *pr) static void bi_write (progs_t *pr) { - int handle = G_INT (pr, OFS_PARM0); - char *buffer = G_STRING (pr, OFS_PARM1); - int count = G_INT (pr, OFS_PARM2); + int handle = P_INT (pr, 0); + char *buffer = P_STRING (pr, 1); + int count = P_INT (pr, 2); - G_INT (pr, OFS_RETURN) = write (handle, buffer, count); + R_INT (pr) = write (handle, buffer, count); } static void bi_seek (progs_t *pr) { - int handle = G_INT (pr, OFS_PARM0); - int pos = G_INT (pr, OFS_PARM1); - int whence = G_INT (pr, OFS_PARM2); + int handle = P_INT (pr, 0); + int pos = P_INT (pr, 1); + int whence = P_INT (pr, 2); - G_INT (pr, OFS_RETURN) = lseek (handle, pos, whence); + R_INT (pr) = lseek (handle, pos, whence); } static void @@ -138,7 +138,7 @@ bi_traceoff (progs_t *pr) static void bi_printf (progs_t *pr) { - const char *fmt = G_STRING (pr, OFS_PARM0); + const char *fmt = P_STRING (pr, 0); char c; int count = 0; float *v; @@ -147,16 +147,16 @@ bi_printf (progs_t *pr) if (c == '%' && count < 7) { switch (c = *fmt++) { case 'i': - fprintf (stdout, "%i", G_INT (pr, OFS_PARM1 + count++ * 3)); + fprintf (stdout, "%i", P_INT (pr, 1 + count++ * 3)); break; case 'f': - fprintf (stdout, "%f", G_FLOAT (pr, OFS_PARM1 + count++ * 3)); + fprintf (stdout, "%f", P_FLOAT (pr, 1 + count++ * 3)); break; case 's': - fputs (G_STRING (pr, OFS_PARM1 + count++ * 3), stdout); + fputs (P_STRING (pr, 1 + count++ * 3), stdout); break; case 'v': - v = G_VECTOR (pr, OFS_PARM1 + count++ * 3); + v = P_VECTOR (pr, 1 + count++ * 3); fprintf (stdout, "'%f %f %f'", v[0], v[1], v[2]); break; default: