Created
May 6, 2011 00:29
-
-
Save branan/958245 to your computer and use it in GitHub Desktop.
Make age private in dirtsand
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint32_t dm_auth_set_private(uint32_t nodeid) { | |
PostgresStrings<4> parms; | |
parms.set(0, nodeid); | |
parms.set(1, DS::Vault::e_NodeAgeInfo); | |
PGresult* result = PQexecParams(s_postgres, | |
"SELECT \"Uuid_1\" FROM vault.\"Nodes\" WHERE idx=$1 AND \"NodeType\"=$2", | |
2, 0, parms.m_values, 0, 0, 0); | |
if (PQresultStatus(result) != PGRES_TUPLES_OK) { | |
fprintf(stderr, "%s:%d:\n Postgres SELECT error: %s\n", | |
__FILE__, __LINE__, PQerrorMessage(s_postgres)); | |
PQclear(result); | |
return DS::e_NetInternalError; | |
} | |
if (PQntuples(result) == 0) { | |
fprintf(stderr, "%s:%d:\n No such ageinfo node: %d\n", | |
__FILE__, __LINE__, nodeid); | |
// the requested age doesn't exist | |
PQclear(result); | |
return DS::e_NetInvalidParameter; | |
} | |
parms.set(0, PQgetvalue(result, 0, 0)); | |
result = PQexecParams(s_postgres, | |
"DELETE FROM game.\"PublicAges\" WHERE \"AgeUuid\"=$1", | |
1, 0, parms.m_values, 0, 0, 0); | |
if (PQresultStatus(result) != PGRES_COMMAND_OK) { | |
fprintf(stderr, "%s:%d:\n Postgres SELECT error: %s\n", | |
__FILE__, __LINE__, PQerrorMessage(s_postgres)); | |
PQclear(result); | |
return DS::e_NetInternalError; | |
} | |
parms.set(0, DS::Vault::e_NodeAgeInfo); | |
parms.set(1, nodeid); | |
result = PQexecParams(s_postgres, | |
"UPDATE vault.\"Nodes\" SET" | |
" \"Int32_2\"=0" | |
" WHERE \"NodeType\"=$1 AND idx=$2", | |
2, 0, parms.m_values, 0, 0, 0); | |
if (PQresultStatus(result) != PGRES_COMMAND_OK) { | |
fprintf(stderr, "%s:%d:\n Postgres UPDATE error: %s\n", | |
__FILE__, __LINE__, PQerrorMessage(s_postgres)); | |
// This doesn't block continuing... | |
} | |
return DS::e_NetSuccess; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment