MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / SQL_FetchFloat

Function SQL_FetchFloat

core/logic/smn_database.cpp:1165–1202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1163}
1164
1165static cell_t SQL_FetchFloat(IPluginContext *pContext, const cell_t *params)
1166{
1167 IQuery *query;
1168 HandleError err;
1169
1170 if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
1171 {
1172 return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
1173 }
1174
1175 IResultSet *rs = query->GetResultSet();
1176 if (!rs)
1177 {
1178 return pContext->ThrowNativeError("No current result set");
1179 }
1180
1181 IResultRow *row = rs->CurrentRow();
1182 if (!row)
1183 {
1184 return pContext->ThrowNativeError("Current result set has no fetched rows");
1185 }
1186
1187 float f;
1188 DBResult res = row->GetFloat(params[2], &f);
1189
1190 if (res == DBVal_Error)
1191 {
1192 return pContext->ThrowNativeError("Error fetching data from field %d", params[2]);
1193 } else if (res == DBVal_TypeMismatch) {
1194 return pContext->ThrowNativeError("Could not fetch data in field %d as a float", params[2]);
1195 }
1196
1197 cell_t *addr;
1198 pContext->LocalToPhysAddr(params[3], &addr);
1199 *addr = (cell_t)res;
1200
1201 return sp_ftoc(f);
1202}
1203
1204static cell_t SQL_FetchInt(IPluginContext *pContext, const cell_t *params)
1205{

Callers

nothing calls this directly

Calls 4

ReadQueryHndlFunction · 0.85
GetResultSetMethod · 0.45
CurrentRowMethod · 0.45
GetFloatMethod · 0.45

Tested by

no test coverage detected