1
0
Fork 0
forked from fte/fteqw

sets the builtin number that the progs is calling. Very useful when the mod tries using a missing builtin.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@98 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2004-09-01 00:04:02 +00:00
parent b5f284f7d6
commit 5679f8248e
4 changed files with 206 additions and 19 deletions

View file

@ -514,6 +514,7 @@ reeval:
{ // negative statements are built in functions { // negative statements are built in functions
i = -newf->first_statement; i = -newf->first_statement;
// p = pr_typecurrent; // p = pr_typecurrent;
progfuncs->lastcalledbuiltinnumber = i;
if (i < externs->numglobalbuiltins) if (i < externs->numglobalbuiltins)
{ {
(*externs->globalbuiltins[i]) (progfuncs, (struct globalvars_s *)current_progstate->globals); (*externs->globalbuiltins[i]) (progfuncs, (struct globalvars_s *)current_progstate->globals);

View file

@ -390,8 +390,8 @@ reeval:
NUM_FOR_EDICT(ed); // make sure it's in range NUM_FOR_EDICT(ed); // make sure it's in range
#endif #endif
if (ed->readonly) if (ed->readonly)
PR_RunError (progfuncs, "assignment to world entity"); PR_RunError (progfuncs, "assignment to read-only entity");
OPC->_int = (int)(((int *)edvars(ed)) + OPB->_int); OPC->_int = (int)(((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust);
break; break;
//load a field to a value //load a field to a value
@ -405,7 +405,7 @@ reeval:
#ifdef PARANOID #ifdef PARANOID
NUM_FOR_EDICT(ed); // make sure it's in range NUM_FOR_EDICT(ed); // make sure it's in range
#endif #endif
ptr = (eval_t *)(((int *)edvars(ed)) + OPB->_int); ptr = (eval_t *)(((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust);
OPC->_int = ptr->_int; OPC->_int = ptr->_int;
break; break;
@ -414,7 +414,7 @@ reeval:
#ifdef PARANOID #ifdef PARANOID
NUM_FOR_EDICT(ed); // make sure it's in range NUM_FOR_EDICT(ed); // make sure it's in range
#endif #endif
ptr = (eval_t *)(((int *)edvars(ed)) + OPB->_int); ptr = (eval_t *)(((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust);
OPC->vector[0] = ptr->vector[0]; OPC->vector[0] = ptr->vector[0];
OPC->vector[1] = ptr->vector[1]; OPC->vector[1] = ptr->vector[1];
OPC->vector[2] = ptr->vector[2]; OPC->vector[2] = ptr->vector[2];
@ -493,6 +493,13 @@ reeval:
#endif #endif
break; break;
} }
/*
{
static char buffer[1024*1024*8];
int size = sizeof buffer;
progfuncs->save_ents(progfuncs, buffer, &size, 0);
}*/
p=pr_typecurrent; p=pr_typecurrent;
//about to switch. needs caching. //about to switch. needs caching.
@ -507,6 +514,7 @@ reeval:
{ // negative statements are built in functions { // negative statements are built in functions
i = -newf->first_statement; i = -newf->first_statement;
// p = pr_typecurrent; // p = pr_typecurrent;
progfuncs->lastcalledbuiltinnumber = i;
if (i < externs->numglobalbuiltins) if (i < externs->numglobalbuiltins)
{ {
(*externs->globalbuiltins[i]) (progfuncs, (struct globalvars_s *)current_progstate->globals); (*externs->globalbuiltins[i]) (progfuncs, (struct globalvars_s *)current_progstate->globals);
@ -525,7 +533,7 @@ reeval:
if (newf->first_statement == -0x7fffffff) if (newf->first_statement == -0x7fffffff)
((builtin_t)newf->profile) (progfuncs, (struct globalvars_s *)current_progstate->globals); ((builtin_t)newf->profile) (progfuncs, (struct globalvars_s *)current_progstate->globals);
else else
PR_RunError (progfuncs, "Bad builtin call number"); PR_RunError (progfuncs, "Bad builtin call number - %i", -newf->first_statement);
} }
else else
current_progstate->builtins [i] (progfuncs, (struct globalvars_s *)current_progstate->globals); current_progstate->builtins [i] (progfuncs, (struct globalvars_s *)current_progstate->globals);
@ -556,6 +564,12 @@ reeval:
pr_globals[OFS_RETURN] = pr_globals[st->a]; pr_globals[OFS_RETURN] = pr_globals[st->a];
pr_globals[OFS_RETURN+1] = pr_globals[st->a+1]; pr_globals[OFS_RETURN+1] = pr_globals[st->a+1];
pr_globals[OFS_RETURN+2] = pr_globals[st->a+2]; pr_globals[OFS_RETURN+2] = pr_globals[st->a+2];
/*
{
static char buffer[1024*1024*8];
int size = sizeof buffer;
progfuncs->save_ents(progfuncs, buffer, &size, 0);
}*/
s = PR_LeaveFunction (progfuncs); s = PR_LeaveFunction (progfuncs);
st = &pr_statements[s]; st = &pr_statements[s];
@ -657,6 +671,8 @@ reeval:
OPC->vector[2] = ptr->vector[2]; OPC->vector[2] = ptr->vector[2];
break; break;
case OP_ADD_SF: //(char*)c = (char*)a + (float)b case OP_ADD_SF: //(char*)c = (char*)a + (float)b
OPC->_int = OPA->_int + (int)OPB->_float; OPC->_int = OPA->_int + (int)OPB->_float;
break; break;
@ -877,6 +893,52 @@ reeval:
} }
break; break;
case OP_MUL_IF:
case OP_MUL_FI:
case OP_MUL_VI:
case OP_DIV_IF:
case OP_DIV_FI:
case OP_BITAND_IF:
case OP_BITOR_IF:
case OP_BITAND_FI:
case OP_BITOR_FI:
case OP_AND_I:
case OP_OR_I:
case OP_AND_IF:
case OP_OR_IF:
case OP_AND_FI:
case OP_OR_FI:
case OP_NOT_I:
case OP_NE_IF:
case OP_NE_FI:
case OP_GSTOREP_I:
case OP_GSTOREP_F:
case OP_GSTOREP_ENT:
case OP_GSTOREP_FLD: // integers
case OP_GSTOREP_S:
case OP_GSTOREP_FNC: // pointers
case OP_GSTOREP_V:
case OP_GADDRESS:
case OP_GLOAD_I:
case OP_GLOAD_F:
case OP_GLOAD_FLD:
case OP_GLOAD_ENT:
case OP_GLOAD_S:
case OP_GLOAD_FNC:
case OP_BOUNDCHECK:
PR_RunError(progfuncs, "Extra opcode not implemented\n");
break;
default: default:
if (st->op & 0x8000) //break point! if (st->op & 0x8000) //break point!
{ {

View file

@ -390,8 +390,8 @@ reeval:
NUM_FOR_EDICT(ed); // make sure it's in range NUM_FOR_EDICT(ed); // make sure it's in range
#endif #endif
if (ed->readonly) if (ed->readonly)
PR_RunError (progfuncs, "assignment to world entity"); PR_RunError (progfuncs, "assignment to read-only entity");
OPC->_int = (int)(((int *)edvars(ed)) + OPB->_int); OPC->_int = (int)(((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust);
break; break;
//load a field to a value //load a field to a value
@ -405,7 +405,7 @@ reeval:
#ifdef PARANOID #ifdef PARANOID
NUM_FOR_EDICT(ed); // make sure it's in range NUM_FOR_EDICT(ed); // make sure it's in range
#endif #endif
ptr = (eval_t *)(((int *)edvars(ed)) + OPB->_int); ptr = (eval_t *)(((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust);
OPC->_int = ptr->_int; OPC->_int = ptr->_int;
break; break;
@ -414,7 +414,7 @@ reeval:
#ifdef PARANOID #ifdef PARANOID
NUM_FOR_EDICT(ed); // make sure it's in range NUM_FOR_EDICT(ed); // make sure it's in range
#endif #endif
ptr = (eval_t *)(((int *)edvars(ed)) + OPB->_int); ptr = (eval_t *)(((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust);
OPC->vector[0] = ptr->vector[0]; OPC->vector[0] = ptr->vector[0];
OPC->vector[1] = ptr->vector[1]; OPC->vector[1] = ptr->vector[1];
OPC->vector[2] = ptr->vector[2]; OPC->vector[2] = ptr->vector[2];
@ -493,6 +493,13 @@ reeval:
#endif #endif
break; break;
} }
/*
{
static char buffer[1024*1024*8];
int size = sizeof buffer;
progfuncs->save_ents(progfuncs, buffer, &size, 0);
}*/
p=pr_typecurrent; p=pr_typecurrent;
//about to switch. needs caching. //about to switch. needs caching.
@ -507,6 +514,7 @@ reeval:
{ // negative statements are built in functions { // negative statements are built in functions
i = -newf->first_statement; i = -newf->first_statement;
// p = pr_typecurrent; // p = pr_typecurrent;
progfuncs->lastcalledbuiltinnumber = i;
if (i < externs->numglobalbuiltins) if (i < externs->numglobalbuiltins)
{ {
(*externs->globalbuiltins[i]) (progfuncs, (struct globalvars_s *)current_progstate->globals); (*externs->globalbuiltins[i]) (progfuncs, (struct globalvars_s *)current_progstate->globals);
@ -525,7 +533,7 @@ reeval:
if (newf->first_statement == -0x7fffffff) if (newf->first_statement == -0x7fffffff)
((builtin_t)newf->profile) (progfuncs, (struct globalvars_s *)current_progstate->globals); ((builtin_t)newf->profile) (progfuncs, (struct globalvars_s *)current_progstate->globals);
else else
PR_RunError (progfuncs, "Bad builtin call number"); PR_RunError (progfuncs, "Bad builtin call number - %i", -newf->first_statement);
} }
else else
current_progstate->builtins [i] (progfuncs, (struct globalvars_s *)current_progstate->globals); current_progstate->builtins [i] (progfuncs, (struct globalvars_s *)current_progstate->globals);
@ -556,6 +564,12 @@ reeval:
pr_globals[OFS_RETURN] = pr_globals[st->a]; pr_globals[OFS_RETURN] = pr_globals[st->a];
pr_globals[OFS_RETURN+1] = pr_globals[st->a+1]; pr_globals[OFS_RETURN+1] = pr_globals[st->a+1];
pr_globals[OFS_RETURN+2] = pr_globals[st->a+2]; pr_globals[OFS_RETURN+2] = pr_globals[st->a+2];
/*
{
static char buffer[1024*1024*8];
int size = sizeof buffer;
progfuncs->save_ents(progfuncs, buffer, &size, 0);
}*/
s = PR_LeaveFunction (progfuncs); s = PR_LeaveFunction (progfuncs);
st = &pr_statements[s]; st = &pr_statements[s];
@ -657,6 +671,8 @@ reeval:
OPC->vector[2] = ptr->vector[2]; OPC->vector[2] = ptr->vector[2];
break; break;
case OP_ADD_SF: //(char*)c = (char*)a + (float)b case OP_ADD_SF: //(char*)c = (char*)a + (float)b
OPC->_int = OPA->_int + (int)OPB->_float; OPC->_int = OPA->_int + (int)OPB->_float;
break; break;
@ -877,6 +893,52 @@ reeval:
} }
break; break;
case OP_MUL_IF:
case OP_MUL_FI:
case OP_MUL_VI:
case OP_DIV_IF:
case OP_DIV_FI:
case OP_BITAND_IF:
case OP_BITOR_IF:
case OP_BITAND_FI:
case OP_BITOR_FI:
case OP_AND_I:
case OP_OR_I:
case OP_AND_IF:
case OP_OR_IF:
case OP_AND_FI:
case OP_OR_FI:
case OP_NOT_I:
case OP_NE_IF:
case OP_NE_FI:
case OP_GSTOREP_I:
case OP_GSTOREP_F:
case OP_GSTOREP_ENT:
case OP_GSTOREP_FLD: // integers
case OP_GSTOREP_S:
case OP_GSTOREP_FNC: // pointers
case OP_GSTOREP_V:
case OP_GADDRESS:
case OP_GLOAD_I:
case OP_GLOAD_F:
case OP_GLOAD_FLD:
case OP_GLOAD_ENT:
case OP_GLOAD_S:
case OP_GLOAD_FNC:
case OP_BOUNDCHECK:
PR_RunError(progfuncs, "Extra opcode not implemented\n");
break;
default: default:
if (st->op & 0x8000) //break point! if (st->op & 0x8000) //break point!
{ {

View file

@ -390,8 +390,8 @@ reeval:
NUM_FOR_EDICT(ed); // make sure it's in range NUM_FOR_EDICT(ed); // make sure it's in range
#endif #endif
if (ed->readonly) if (ed->readonly)
PR_RunError (progfuncs, "assignment to world entity"); PR_RunError (progfuncs, "assignment to read-only entity");
OPC->_int = (int)(((int *)edvars(ed)) + OPB->_int); OPC->_int = (int)(((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust);
break; break;
//load a field to a value //load a field to a value
@ -405,7 +405,7 @@ reeval:
#ifdef PARANOID #ifdef PARANOID
NUM_FOR_EDICT(ed); // make sure it's in range NUM_FOR_EDICT(ed); // make sure it's in range
#endif #endif
ptr = (eval_t *)(((int *)edvars(ed)) + OPB->_int); ptr = (eval_t *)(((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust);
OPC->_int = ptr->_int; OPC->_int = ptr->_int;
break; break;
@ -414,7 +414,7 @@ reeval:
#ifdef PARANOID #ifdef PARANOID
NUM_FOR_EDICT(ed); // make sure it's in range NUM_FOR_EDICT(ed); // make sure it's in range
#endif #endif
ptr = (eval_t *)(((int *)edvars(ed)) + OPB->_int); ptr = (eval_t *)(((int *)edvars(ed)) + OPB->_int + progfuncs->fieldadjust);
OPC->vector[0] = ptr->vector[0]; OPC->vector[0] = ptr->vector[0];
OPC->vector[1] = ptr->vector[1]; OPC->vector[1] = ptr->vector[1];
OPC->vector[2] = ptr->vector[2]; OPC->vector[2] = ptr->vector[2];
@ -493,6 +493,13 @@ reeval:
#endif #endif
break; break;
} }
/*
{
static char buffer[1024*1024*8];
int size = sizeof buffer;
progfuncs->save_ents(progfuncs, buffer, &size, 0);
}*/
p=pr_typecurrent; p=pr_typecurrent;
//about to switch. needs caching. //about to switch. needs caching.
@ -507,6 +514,7 @@ reeval:
{ // negative statements are built in functions { // negative statements are built in functions
i = -newf->first_statement; i = -newf->first_statement;
// p = pr_typecurrent; // p = pr_typecurrent;
progfuncs->lastcalledbuiltinnumber = i;
if (i < externs->numglobalbuiltins) if (i < externs->numglobalbuiltins)
{ {
(*externs->globalbuiltins[i]) (progfuncs, (struct globalvars_s *)current_progstate->globals); (*externs->globalbuiltins[i]) (progfuncs, (struct globalvars_s *)current_progstate->globals);
@ -525,7 +533,7 @@ reeval:
if (newf->first_statement == -0x7fffffff) if (newf->first_statement == -0x7fffffff)
((builtin_t)newf->profile) (progfuncs, (struct globalvars_s *)current_progstate->globals); ((builtin_t)newf->profile) (progfuncs, (struct globalvars_s *)current_progstate->globals);
else else
PR_RunError (progfuncs, "Bad builtin call number"); PR_RunError (progfuncs, "Bad builtin call number - %i", -newf->first_statement);
} }
else else
current_progstate->builtins [i] (progfuncs, (struct globalvars_s *)current_progstate->globals); current_progstate->builtins [i] (progfuncs, (struct globalvars_s *)current_progstate->globals);
@ -556,6 +564,12 @@ reeval:
pr_globals[OFS_RETURN] = pr_globals[st->a]; pr_globals[OFS_RETURN] = pr_globals[st->a];
pr_globals[OFS_RETURN+1] = pr_globals[st->a+1]; pr_globals[OFS_RETURN+1] = pr_globals[st->a+1];
pr_globals[OFS_RETURN+2] = pr_globals[st->a+2]; pr_globals[OFS_RETURN+2] = pr_globals[st->a+2];
/*
{
static char buffer[1024*1024*8];
int size = sizeof buffer;
progfuncs->save_ents(progfuncs, buffer, &size, 0);
}*/
s = PR_LeaveFunction (progfuncs); s = PR_LeaveFunction (progfuncs);
st = &pr_statements[s]; st = &pr_statements[s];
@ -657,6 +671,8 @@ reeval:
OPC->vector[2] = ptr->vector[2]; OPC->vector[2] = ptr->vector[2];
break; break;
case OP_ADD_SF: //(char*)c = (char*)a + (float)b case OP_ADD_SF: //(char*)c = (char*)a + (float)b
OPC->_int = OPA->_int + (int)OPB->_float; OPC->_int = OPA->_int + (int)OPB->_float;
break; break;
@ -877,6 +893,52 @@ reeval:
} }
break; break;
case OP_MUL_IF:
case OP_MUL_FI:
case OP_MUL_VI:
case OP_DIV_IF:
case OP_DIV_FI:
case OP_BITAND_IF:
case OP_BITOR_IF:
case OP_BITAND_FI:
case OP_BITOR_FI:
case OP_AND_I:
case OP_OR_I:
case OP_AND_IF:
case OP_OR_IF:
case OP_AND_FI:
case OP_OR_FI:
case OP_NOT_I:
case OP_NE_IF:
case OP_NE_FI:
case OP_GSTOREP_I:
case OP_GSTOREP_F:
case OP_GSTOREP_ENT:
case OP_GSTOREP_FLD: // integers
case OP_GSTOREP_S:
case OP_GSTOREP_FNC: // pointers
case OP_GSTOREP_V:
case OP_GADDRESS:
case OP_GLOAD_I:
case OP_GLOAD_F:
case OP_GLOAD_FLD:
case OP_GLOAD_ENT:
case OP_GLOAD_S:
case OP_GLOAD_FNC:
case OP_BOUNDCHECK:
PR_RunError(progfuncs, "Extra opcode not implemented\n");
break;
default: default:
if (st->op & 0x8000) //break point! if (st->op & 0x8000) //break point!
{ {