SQInteger sq_setTextPositionForAll(SQVM * pVM) { SQInteger textId; float x, y; sq_getfloat(pVM, -1, &y); sq_getfloat(pVM, -2, &x); sq_getinteger(pVM, -3, &textId); if(pNetowkManager->GetTextManager()->GetSlotState(textId)) { pNetowkManager->GetTextManager()->GetAt(textId)->SetPosition(x, y); } sq_pushbool(pVM, false); return 1; }
SQInteger CActorNatives::DriveToCoordinates(SQVM * pVM) { EntityId actorId; sq_getentity(pVM,-4, &actorId); CVector3 vecPos; sq_getfloat(pVM, -3, &vecPos.fX); sq_getfloat(pVM, -2, &vecPos.fY); sq_getfloat(pVM, -1, &vecPos.fZ); if(g_pActorManager->DoesExist(actorId)) { g_pActorManager->DriveToCoordinates(actorId, vecPos, CVector3()); if(!g_pActorManager->UpdateDrivePos(actorId, vecPos, CVector3(), false)) CLogFile::Printf("Failed to set actor's %d state to driving(not in a vehicle!)",actorId); } return 1; }
SQInteger with_assert_sq_getfloat(HSQUIRRELVM v,SQInteger nargs,float & val){ SQInteger st_nargs = sq_gettop(v); if(st_nargs < nargs) return sq_throwerror(v, "too many args"); if(sq_gettype(v,nargs) != OT_FLOAT) return sq_throwerror(v, "param is not float"); sq_getfloat(v,nargs,&val); return 0; }
SQInteger SFScriptRegisterNumericVariable(HSQUIRRELVM v) { char *name; SQFloat value; sq_getstring(Scripts.vm, 2, (const char **)&name); sq_getfloat(Scripts.vm, 3, &value); ScriptsRegisterNumericVariable(name, value); return 0; }
_MEMBER_FUNCTION_IMPL(GUIElement, setRotation) { float x, y, z; sq_getfloat(pVM, -1, &z); sq_getfloat(pVM, -2, &y); sq_getfloat(pVM, -3, &x); CGUIFrameWindow * pWindow = sq_getinstance<CGUIFrameWindow *>(pVM); if(!pWindow) { sq_pushbool(pVM, false); return 1; } pWindow->setRotation(CEGUI::Vector3(x, y, z)); sq_pushbool(pVM, true); return 1; }
float SquirrelObject::GetFloat(const SQChar *key) /*const*/ { float ret = 0.0f; if(GetSlot(key)) { sq_getfloat(m_Vm.GetVMPtr(),-1,&ret); sq_pop(m_Vm.GetVMPtr(),1); } sq_pop(m_Vm.GetVMPtr(),1); return ret; }
// createActor(modelhash, x, y, z, r) SQInteger CActorNatives::Create(SQVM * pVM) { SQInteger iModelId; CVector3 vecPosition; float fHeading; sq_getinteger(pVM, -5, &iModelId); sq_getvector3(pVM, -4, &vecPosition); sq_getfloat(pVM, -1, &fHeading); sq_pushentity(pVM, g_pActorManager->Create(iModelId, vecPosition, fHeading)); return 1; }
void CSquirrelVM::Pop(float& f) { SQObjectType argType = sq_gettype(m_pVM, m_iStackIndex); if (argType == OT_FLOAT) { sq_getfloat(m_pVM, m_iStackIndex++, &f); return; } f = 0; m_iStackIndex++; }
// createCheckpoint(type, x, y, z, targetx, targety, targetz, radius) SQInteger CCheckpointNatives::Create(SQVM * pVM) { SQInteger iType; CVector3 vecPosition; CVector3 vecTargetPosition; float fRadius; sq_getinteger(pVM, -8, &iType); sq_getvector3(pVM, -7, &vecPosition); sq_getvector3(pVM, -4, &vecTargetPosition); sq_getfloat(pVM, -1, &fRadius); sq_pushentity(pVM, g_pCheckpointManager->Add(iType, vecPosition, vecTargetPosition, fRadius)); return 1; }
SQInteger SFVectorDirection(HSQUIRRELVM v) { SQFloat x1; SQFloat y1; SQFloat x2; SQFloat y2; SQFloat dir; sq_getfloat(Scripts.vm, 2, &x1); sq_getfloat(Scripts.vm, 3, &y1); sq_getfloat(Scripts.vm, 4, &x2); sq_getfloat(Scripts.vm, 5, &y2); dir = acos((x2 - x1) / sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2))); if (y2 > y1) { dir = M_PI * 2 - dir; } sq_pushfloat(Scripts.vm, dir); return 1; }
SQInteger SFRound(HSQUIRRELVM v) { SQFloat x; sq_getfloat(Scripts.vm, 2, &x); #ifndef CC_DJGPP sq_pushfloat(Scripts.vm, round(x)); #else if (floor(x) < x - 0.5) sq_pushfloat(Scripts.vm, ceil(x)); else sq_pushfloat(Scripts.vm, floor(x)); #endif return 1; }
SQInteger SFPhysicsObjectCreate(HSQUIRRELVM v) { int x; int y; int width; int height; SQFloat mass; sq_getinteger(Scripts.vm, 2, &x); sq_getinteger(Scripts.vm, 3, &y); sq_getinteger(Scripts.vm, 4, &width); sq_getinteger(Scripts.vm, 5, &height); sq_getfloat(Scripts.vm, 6, &mass); sq_pushinteger(Scripts.vm, PhysicsPlaceObject(x, y, width, height, mass)); return 1; }
/* * get instance member value as float */ bool getInstanceMemberAsFloat(HSQUIRRELVM v, int idx, const char *name, SQFloat* value) { if (sq_gettype(v, idx) == OT_NULL) return false; sq_pushstring(v, name, -1); if (!SQ_SUCCEEDED(sq_get(v, idx))) { sq_pop(v, 1); return false; } if (sq_gettype(v, -1) == OT_NULL) { sq_pop(v, 1); return false; } sq_getfloat(v, -1, value); sq_pop(v, 1); return true; }
_MEMBER_FUNCTION_IMPL(GUIElement, setAlpha) { float alpha; sq_getfloat(pVM, -1, &alpha); CGUIFrameWindow * pWindow = sq_getinstance<CGUIFrameWindow *>(pVM); if(!pWindow) { sq_pushbool(pVM, false); return 1; } pWindow->setAlpha(alpha); sq_pushbool(pVM, true); return 1; }
// setActorHeading(actorid, r) SQInteger CActorNatives::SetHeading(SQVM * pVM) { EntityId actorId; float fHeading; sq_getentity(pVM, -2, &actorId); sq_getfloat(pVM, -1, &fHeading); if(g_pActorManager->DoesExist(actorId)) { g_pActorManager->SetHeading(actorId, fHeading); sq_pushbool(pVM, true); return 1; } sq_pushbool(pVM, false); return 1; }
SQInteger SFSign(HSQUIRRELVM v) { SQFloat x; sq_getfloat(Scripts.vm, 2, &x); if (x < 0) { sq_pushinteger(Scripts.vm, -1); } if (x == 0) { sq_pushinteger(Scripts.vm, 0); } if (x > 0) { sq_pushinteger(Scripts.vm, 1); } return 1; }
// setCheckpointRadius(checkpointid, radius) SQInteger CCheckpointNatives::SetRadius(SQVM * pVM) { EntityId checkpointId; float fRadius; sq_getentity(pVM, -2, &checkpointId); sq_getfloat(pVM, -1, &fRadius); CCheckpoint * pCheckpoint = g_pCheckpointManager->Get(checkpointId); if(pCheckpoint) { pCheckpoint->SetRadius(fRadius); sq_pushbool(pVM, true); return 1; } sq_pushbool(pVM, false); return 1; }
void CSquirrelVM::Pop(float& f, float fDefaultValue) { SQObjectType argType = sq_gettype(m_pVM, m_iStackIndex); if (argType == OT_FLOAT) { sq_getfloat(m_pVM, m_iStackIndex++, &f); return; } else { if(argType == OT_NULL) { f = fDefaultValue; m_iStackIndex++; return; } } f = 0; m_iStackIndex++; }
float read_float(HSQUIRRELVM vm, const char* name) { sq_pushstring(vm, name, -1); if(SQ_FAILED(sq_get(vm, -2))) { std::ostringstream msg; msg << "Couldn't get float value for '" << name << "' from table"; throw scripting::SquirrelError(vm, msg.str()); } float result; if(SQ_FAILED(sq_getfloat(vm, -1, &result))) { std::ostringstream msg; msg << "Couldn't get float value for '" << name << "' from table"; throw scripting::SquirrelError(vm, msg.str()); } sq_pop(vm, 1); return result; }
_MEMBER_FUNCTION_IMPL(GUIProgressBar, setValue) { CEGUI::Window * pWindow = sq_getinstance<CEGUI::Window *>(pVM); float fCurrentValue = 0.0f; sq_getfloat(pVM, 2, &fCurrentValue); if ( fCurrentValue > 100.0f || fCurrentValue < 0.0f ) { CLogFile::Printf("Invalid first argument value. (Argument accept values from 0.0 to 100.0 [float], your value %f)", fCurrentValue); sq_pushbool(pVM, false); } char szNewProgress[4]; sprintf(szNewProgress, "%f", fCurrentValue*0.01); pWindow->setProperty("CurrentProgress", szNewProgress); sq_pushbool(pVM, true); return 1; }
// setWeather(weather) SQInteger CServerNatives::ForceWind(SQVM * pVM) { SQFloat fWind; sq_getfloat(pVM, 2, &fWind); if(fWind != CVAR_GET_INTEGER("wind")) { CVAR_SET_FLOAT("wind", (float)fWind); CBitStream bsSend; bsSend.Write((float)fWind); g_pNetworkManager->RPC(RPC_ScriptingForceWind, &bsSend, PRIORITY_HIGH, RELIABILITY_RELIABLE_ORDERED, INVALID_ENTITY_ID, true); sq_pushbool(pVM, true); return 1; } sq_pushbool(pVM, false); return 1; }
static SQRESULT squirrel_get_typedvalue(HSQUIRRELVM v, SQInteger idx, WasmInterpreterTypedValue* out_tv) { SQObjectType type = sq_gettype(v, idx); switch (type) { case OT_INTEGER: { SQInteger value; sq_getinteger(v, idx, &value); if (sizeof(SQInteger) == sizeof(uint32_t)) { out_tv->type = WASM_TYPE_I32; out_tv->value.i32 = value; } else if (sizeof(SQInteger) == sizeof(uint64_t)) { out_tv->type = WASM_TYPE_I64; out_tv->value.i64 = value; } return SQ_OK; } case OT_FLOAT: { SQFloat value; sq_getfloat(v, idx, &value); if (sizeof(SQFloat) == sizeof(float)) { out_tv->type = WASM_TYPE_F32; out_tv->value.f32_bits = bitcast_f32_to_u32(value); } else if (sizeof(SQFloat) == sizeof(double)) { out_tv->type = WASM_TYPE_F64; out_tv->value.f64_bits = bitcast_f64_to_u64(value); } return SQ_OK; } case OT_NULL: { out_tv->type = WASM_TYPE_VOID; return SQ_OK; } default: return sq_throwerror(v, "unexpected type."); } }
SQInteger SFDrawAddSpriteAngled(HSQUIRRELVM v) { int spriteNum; int clipNum; int x; int y; int centerX; int centerY; SQFloat angle; sq_getinteger(Scripts.vm, 2, &spriteNum); sq_getinteger(Scripts.vm, 3, &clipNum); sq_getinteger(Scripts.vm, 4, &x); sq_getinteger(Scripts.vm, 5, &y); sq_getinteger(Scripts.vm, 6, ¢erX); sq_getinteger(Scripts.vm, 7, ¢erY); sq_getfloat(Scripts.vm, 8, &angle); DrawAddSpriteAngled(spriteNum, clipNum, x, y, centerX, centerY, angle); return 0; }
// createPickup(modelhash, type, value?, x, y, z, rx, ry, rz) SQInteger CPickupNatives::Create(SQVM * pVM) { SQInteger modelhash, type, value; float x, y, z, rx, ry, rz; sq_getinteger(pVM, 2, &modelhash); sq_getinteger(pVM, 3, &type); sq_getinteger(pVM, 4, &value); sq_getfloat(pVM, 5, &x); sq_getfloat(pVM, 6, &y); sq_getfloat(pVM, 7, &z); sq_getfloat(pVM, 8, &rx); sq_getfloat(pVM, 9, &ry); sq_getfloat(pVM, 10, &rz); sq_pushinteger(pVM, g_pPickupManager->Create(modelhash, (unsigned char)type, (unsigned int)value, x, y, z, rx, ry, rz)); return 1; }
// setVehicleFuel( vehicleid, speed ); SQInteger CSharedVehicleNatives::SetFuel( SQVM * pVM ) { // Get the vehicle id SQInteger vehicleId; sq_getinteger( pVM, -2, &vehicleId ); // Get the fuel SQFloat fFuel; sq_getfloat( pVM, -1, &fFuel ); // Is the vehicle active? if( pCore->GetVehicleManager()->IsActive( vehicleId ) ) { // Set the vehicle fuel pCore->GetVehicleManager()->Get( vehicleId )->SetFuel ( fFuel ); sq_pushbool ( pVM, true ); return 1; } sq_pushbool( pVM, false ); return 1; }
void PrintCallStack(HSQUIRRELVM v) { SQPRINTFUNCTION pf = sq_geterrorfunc(v); if(pf) { SQStackInfos si; SQInteger i; SQFloat f; const SQChar *s; SQInteger level=1; //1 is to skip this function that is level 0 const SQChar *name=0; SQInteger seq=0; pf(v,_SC("\nCALLSTACK\n")); while(SQ_SUCCEEDED(sq_stackinfos(v,level,&si))) { const SQChar *fn=_SC("unknown"); const SQChar *src=_SC("unknown"); if(si.funcname)fn=si.funcname; if(si.source)src=si.source; pf(v,_SC("*FUNCTION [%s()] %s line [%d]\n"),fn,src,si.line); level++; } return; level=0; pf(v,_SC("\nLOCALS\n")); for(level=0;level<10;level++){ seq=0; while((name = sq_getlocal(v,level,seq))) { seq++; switch(sq_gettype(v,-1)) { case OT_NULL: pf(v,_SC("[%s] NULL\n"),name); break; case OT_INTEGER: sq_getinteger(v,-1,&i); pf(v,_SC("[%s] %d\n"),name,i); break; case OT_FLOAT: sq_getfloat(v,-1,&f); pf(v,_SC("[%s] %.14g\n"),name,f); break; case OT_USERPOINTER: pf(v,_SC("[%s] USERPOINTER\n"),name); break; case OT_STRING: sq_getstring(v,-1,&s); pf(v,_SC("[%s] \"%s\"\n"),name,s); break; case OT_TABLE: pf(v,_SC("[%s] TABLE\n"),name); break; case OT_ARRAY: pf(v,_SC("[%s] ARRAY\n"),name); break; case OT_CLOSURE: pf(v,_SC("[%s] CLOSURE\n"),name); break; case OT_NATIVECLOSURE: pf(v,_SC("[%s] NATIVECLOSURE\n"),name); break; case OT_GENERATOR: pf(v,_SC("[%s] GENERATOR\n"),name); break; case OT_USERDATA: pf(v,_SC("[%s] USERDATA\n"),name); break; case OT_THREAD: pf(v,_SC("[%s] THREAD\n"),name); break; case OT_CLASS: pf(v,_SC("[%s] CLASS\n"),name); break; case OT_INSTANCE: pf(v,_SC("[%s] INSTANCE\n"),name); break; case OT_WEAKREF: pf(v,_SC("[%s] WEAKREF\n"),name); break; case OT_BOOL:{ sq_getinteger(v,-1,&i); pf(v,_SC("[%s] %s\n"),name,i?_SC("true"):_SC("false")); } break; default: ROCKETSQUIRREL_ASSERT(0); break; } sq_pop(v,1); } } } }
SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen,SQChar **output) { const SQChar *format; SQChar *dest; SQChar fmt[MAX_FORMAT_LEN]; sq_getstring(v,nformatstringidx,&format); SQInteger allocated = (sq_getsize(v,nformatstringidx)+2)*sizeof(SQChar); dest = sq_getscratchpad(v,allocated); SQInteger n = 0,i = 0, nparam = nformatstringidx+1, w = 0; while(format[n] != '\0') { if(format[n] != '%') { assert(i < allocated); dest[i++] = format[n]; n++; } else if(format[n+1] == '%') { //handles %% dest[i++] = '%'; n += 2; } else { n++; if( nparam > sq_gettop(v) ) return sq_throwerror(v,_SC("not enough paramters for the given format string")); n = validate_format(v,fmt,format,n,w); if(n < 0) return -1; SQInteger addlen = 0; SQInteger valtype = 0; const SQChar *ts; SQInteger ti; SQFloat tf; switch(format[n]) { case 's': if(SQ_FAILED(sq_getstring(v,nparam,&ts))) return sq_throwerror(v,_SC("string expected for the specified format")); addlen = (sq_getsize(v,nparam)*sizeof(SQChar))+((w+1)*sizeof(SQChar)); valtype = 's'; break; case 'i': case 'd': case 'o': case 'u': case 'x': case 'X': #ifdef _SQ64 { size_t flen = scstrlen(fmt); SQInteger fpos = flen - 1; SQChar f = fmt[fpos]; SQChar *prec = (SQChar *)_PRINT_INT_PREC; while(*prec != _SC('\0')) { fmt[fpos++] = *prec++; } fmt[fpos++] = f; fmt[fpos++] = _SC('\0'); } #endif case 'c': if(SQ_FAILED(sq_getinteger(v,nparam,&ti))) return sq_throwerror(v,_SC("integer expected for the specified format")); addlen = (ADDITIONAL_FORMAT_SPACE)+((w+1)*sizeof(SQChar)); valtype = 'i'; break; case 'f': case 'g': case 'G': case 'e': case 'E': if(SQ_FAILED(sq_getfloat(v,nparam,&tf))) return sq_throwerror(v,_SC("float expected for the specified format")); addlen = (ADDITIONAL_FORMAT_SPACE)+((w+1)*sizeof(SQChar)); valtype = 'f'; break; default: return sq_throwerror(v,_SC("invalid format")); } n++; allocated += addlen + sizeof(SQChar); dest = sq_getscratchpad(v,allocated); switch(valtype) { #pragma warning(push) #pragma warning(disable : 4996) case 's': i += scsprintf(&dest[i],fmt,ts); break; case 'i': i += scsprintf(&dest[i],fmt,ti); break; case 'f': i += scsprintf(&dest[i],fmt,tf); break; #pragma warning(pop) }; nparam ++; } } *outlen = i; dest[i] = '\0'; *output = dest; return SQ_OK; }
static SQInteger _string_format( HSQUIRRELVM v ) { const SQChar *format; SQChar *dest; SQChar fmt[MAX_FORMAT_LEN]; sq_getstring( v, 2, &format ); SQInteger allocated = ( sq_getsize( v, 2 ) + 1 ) * sizeof( SQChar ); dest = sq_getscratchpad( v, allocated ); SQInteger n = 0, i = 0, nparam = 3, w = 0; while ( format[n] != '\0' ) { if ( format[n] != '%' ) { assert( i < allocated ); dest[i++] = format[n]; n++; } else if ( format[n+1] == '%' ) { //handles %% dest[i++] = '%'; n += 2; } else { n++; if ( nparam > sq_gettop( v ) ) return sq_throwerror( v, _SC( "not enough paramters for the given format string" ) ); n = validate_format( v, fmt, format, n, w ); if ( n < 0 ) return -1; SQInteger addlen = 0; SQInteger valtype = 0; const SQChar *ts; SQInteger ti; SQFloat tf; switch ( format[n] ) { case 's': if ( SQ_FAILED( sq_getstring( v, nparam, &ts ) ) ) return sq_throwerror( v, _SC( "string expected for the specified format" ) ); addlen = ( sq_getsize( v, nparam ) * sizeof( SQChar ) ) + ( ( w + 1 ) * sizeof( SQChar ) ); valtype = 's'; break; case 'i': case 'd': case 'c': case 'o': case 'u': case 'x': case 'X': if ( SQ_FAILED( sq_getinteger( v, nparam, &ti ) ) ) return sq_throwerror( v, _SC( "integer expected for the specified format" ) ); addlen = ( ADDITIONAL_FORMAT_SPACE ) + ( ( w + 1 ) * sizeof( SQChar ) ); valtype = 'i'; break; case 'f': case 'g': case 'G': case 'e': case 'E': if ( SQ_FAILED( sq_getfloat( v, nparam, &tf ) ) ) return sq_throwerror( v, _SC( "float expected for the specified format" ) ); addlen = ( ADDITIONAL_FORMAT_SPACE ) + ( ( w + 1 ) * sizeof( SQChar ) ); valtype = 'f'; break; default: return sq_throwerror( v, _SC( "invalid format" ) ); } n++; //if((allocated-i) < addlen) allocated += addlen; dest = sq_getscratchpad( v, allocated ); switch ( valtype ) { case 's': i += scsprintf( &dest[i], fmt, ts ); break; case 'i': i += scsprintf( &dest[i], fmt, ti ); break; case 'f': i += scsprintf( &dest[i], fmt, tf ); break; }; nparam ++; } } sq_pushstring( v, dest, i ); return 1; }
SQInteger _stream_writen(HSQUIRRELVM v) { SETUP_STREAM(v); SQInteger format, ti; SQFloat tf; sq_getinteger(v, 3, &format); switch(format) { case 'l': { SQInteger i; sq_getinteger(v, 2, &ti); i = ti; self->Write(&i, sizeof(SQInteger)); } break; case 'i': { SQInt32 i; sq_getinteger(v, 2, &ti); i = (SQInt32)ti; self->Write(&i, sizeof(SQInt32)); } break; case 's': { short s; sq_getinteger(v, 2, &ti); s = (short)ti; self->Write(&s, sizeof(short)); } break; case 'w': { unsigned short w; sq_getinteger(v, 2, &ti); w = (unsigned short)ti; self->Write(&w, sizeof(unsigned short)); } break; case 'c': { char c; sq_getinteger(v, 2, &ti); c = (char)ti; self->Write(&c, sizeof(char)); } break; case 'b': { unsigned char b; sq_getinteger(v, 2, &ti); b = (unsigned char)ti; self->Write(&b, sizeof(unsigned char)); } break; case 'f': { float f; sq_getfloat(v, 2, &tf); f = (float)tf; self->Write(&f, sizeof(float)); } break; case 'd': { double d; sq_getfloat(v, 2, &tf); d = tf; self->Write(&d, sizeof(double)); } break; default: return sq_throwerror(v, _SC("invalid format")); } return 0; }
SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen,SQChar **output) { const SQChar *format; SQChar *dest; SQChar fmt[MAX_FORMAT_LEN]; sq_getstring(v,nformatstringidx,&format); SQInteger allocated = (sq_getsize(v,nformatstringidx)+2)*sizeof(SQChar); dest = sq_getscratchpad(v,allocated); SQInteger n = 0,i = 0, nparam = nformatstringidx+1, w = 0; while(format[n] != '\0') { if(format[n] != '%') { assert(i < allocated); dest[i++] = format[n]; n++; } else if(format[n+1] == '%') { //handles %% dest[i++] = '%'; n += 2; } else { n++; if( nparam > sq_gettop(v) ) // C::B patch: Correct misspelled "parameters" return sq_throwerror(v,_SC("not enough parameters for the given format string")); n = validate_format(v,fmt,format,n,w); if(n < 0) return -1; SQInteger addlen = 0; SQInteger valtype = 0; const SQChar *ts; SQInteger ti; SQFloat tf; switch(format[n]) { case 's': if(SQ_FAILED(sq_getstring(v,nparam,&ts))) return sq_throwerror(v,_SC("string expected for the specified format")); addlen = (sq_getsize(v,nparam)*sizeof(SQChar))+((w+1)*sizeof(SQChar)); valtype = 's'; break; case 'i': case 'd': case 'c':case 'o': case 'u': case 'x': case 'X': if(SQ_FAILED(sq_getinteger(v,nparam,&ti))) return sq_throwerror(v,_SC("integer expected for the specified format")); addlen = (ADDITIONAL_FORMAT_SPACE)+((w+1)*sizeof(SQChar)); valtype = 'i'; break; case 'f': case 'g': case 'G': case 'e': case 'E': if(SQ_FAILED(sq_getfloat(v,nparam,&tf))) return sq_throwerror(v,_SC("float expected for the specified format")); addlen = (ADDITIONAL_FORMAT_SPACE)+((w+1)*sizeof(SQChar)); valtype = 'f'; break; default: return sq_throwerror(v,_SC("invalid format")); } n++; allocated += addlen + sizeof(SQChar); dest = sq_getscratchpad(v,allocated); switch(valtype) { case 's': i += scsprintf(&dest[i],fmt,ts); break; case 'i': i += scsprintf(&dest[i],fmt,ti); break; case 'f': i += scsprintf(&dest[i],fmt,tf); break; }; nparam ++; } } *outlen = i; dest[i] = '\0'; *output = dest; return SQ_OK; }