예제 #1
0
void CookieManager::ClientConnectCallback(int serial, IQuery *data)
{
	int client;

	/* Check validity of client */
	if ((client = playerhelpers->GetClientFromSerial(serial)) == 0)
	{
		return;
	}
	statsPending[client] = false;
	
	IResultSet *results;
	/* Check validity of results */
	if (data == NULL || (results = data->GetResultSet()) == NULL)
	{
		return;
	}

	CookieData *pData;
	IResultRow *row;
	unsigned int timestamp;
	CookieAccess access;
	
	while (results->MoreRows() && ((row = results->FetchRow()) != NULL))
	{
		const char *name = "";
		row->GetString(0, &name, NULL);
		
		const char *value = "";
		row->GetString(1, &value, NULL);

		pData = new CookieData(value);
		pData->changed = false;

		pData->timestamp = (row->GetInt(4, (int *)&timestamp) == DBVal_Data) ? timestamp : 0;

		Cookie *parent = FindCookie(name);

		if (parent == NULL)
		{
			const char *desc = "";
			row->GetString(2, &desc, NULL);

			access = CookieAccess_Public;
			row->GetInt(3, (int *)&access);

			parent = CreateCookie(name, desc, access);
		}

		pData->parent = parent;
		parent->data[client] = pData;
		clientData[client].append(pData);
	}

	statsLoaded[client] = true;

	cookieDataLoadedForward->PushCell(client);
	cookieDataLoadedForward->Execute(NULL);
}
예제 #2
0
void CookieManager::SelectIdCallback(Cookie *pCookie, IQuery *data)
{
	IResultSet *results;
	
	if (data == NULL || (results = data->GetResultSet()) == NULL)
	{
		return;
	}

	IResultRow *row = results->FetchRow();

	if (row == NULL)
	{
		return;
	}

	row->GetInt(0, &pCookie->dbid);
}
예제 #3
0
static cell_t SQL_FetchRow(IPluginContext *pContext, const cell_t *params)
{
	IQuery *query;
	HandleError err;

	if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
	}

	IResultSet *rs = query->GetResultSet();
	if (!rs)
	{
		return pContext->ThrowNativeError("No current result set");
	}

	return (rs->FetchRow() != NULL) ? true : false;
}
예제 #4
0
파일: cookie.cpp 프로젝트: asceth/synapi
void CookieManager::ClientConnectCallback(int serial, IQuery *data)
{
    int client;
    IResultSet *results;

    /* Check validity of client */
    if ((client = playerhelpers->GetClientFromSerial(serial)) == 0)
    {
        return;
    }

    /* Check validity of results */
    if (data == NULL || (results = data->GetResultSet()) == NULL)
    {
        return;
    }

    IResultRow *row;
    do
    {
        if ((row = results->FetchRow()) == NULL)
        {
            break;
        }

        const char *name;
        row->GetString(0, &name, NULL);

        const char *value;
        row->GetString(1, &value, NULL);

        CookieData *pData = new CookieData(value);
        pData->changed = false;

        Cookie *parent = FindCookie(name);

        if (parent == NULL)
        {
            const char *desc;
            row->GetString(2, &desc, NULL);

            CookieAccess access = CookieAccess_Public;
            row->GetInt(3, (int *)&access);

            parent = CreateCookie(name, desc, access);
            cookieTrie.insert(name, parent);
            cookieList.push_back(parent);
        }

        pData->parent = parent;
        parent->data[client] = pData;

        clientData[client].push_back(pData);

    } while (results->MoreRows());

    statsLoaded[client] = true;

    cookieDataLoadedForward->PushCell(client);
    cookieDataLoadedForward->Execute(NULL);
}