Fix some warnings

This commit is contained in:
Jack Bond-Preston 2016-08-11 20:21:46 +01:00
parent e4cc023055
commit ec19b784b3
5 changed files with 6 additions and 21 deletions

View File

@ -100,7 +100,7 @@ void GatewayHandler::on_hello(json decoded, client &c, websocketpp::connection_h
send_identify(c, hdl); send_identify(c, hdl);
} }
void GatewayHandler::on_dispatch(json decoded, client &c, websocketpp::connection_hdl &hdl) { void GatewayHandler::on_dispatch(json decoded, client &, websocketpp::connection_hdl &) {
last_seq = decoded["s"]; last_seq = decoded["s"];
std::string event_name = decoded["t"]; std::string event_name = decoded["t"];
json data = decoded["d"]; json data = decoded["d"];
@ -382,7 +382,6 @@ void GatewayHandler::on_event_guild_role_delete(json data) {
auto it = roles.find(role_id); auto it = roles.find(role_id);
if (it != roles.end()) { if (it != roles.end()) {
DiscordObjects::Role &role = roles[role_id];
DiscordObjects::Guild &guild = guilds[data["guild_id"]]; DiscordObjects::Guild &guild = guilds[data["guild_id"]];
auto check_lambda = [role_id](const DiscordObjects::Role *r) { auto check_lambda = [role_id](const DiscordObjects::Role *r) {

View File

@ -28,6 +28,8 @@ namespace Logger {
case LogLevel::Warning: case LogLevel::Warning:
return std::cerr; return std::cerr;
} }
return std::cerr;
} }
void write(std::string text, LogLevel log_level) { void write(std::string text, LogLevel log_level) {

View File

@ -105,7 +105,7 @@ TriviaGame::~TriviaGame() {
std::string update_sql; std::string update_sql;
if (data.size() < scores.size()) { // some users dont have entries yet if (data.size() < scores.size()) { // some users dont have entries yet
std::string sql = "INSERT INTO TotalScores (User, TotalScore, AverageTime) VALUES "; sql = "INSERT INTO TotalScores (User, TotalScore, AverageTime) VALUES ";
for (auto &i : scores) { for (auto &i : scores) {
if (data.find(i.first) == data.end()) { if (data.find(i.first) == data.end()) {
sql += "(?, ?, ?),"; sql += "(?, ?, ?),";
@ -252,8 +252,8 @@ void TriviaGame::give_hint(int hints_given, std::string hint) {
// count number of *s // count number of *s
int length = 0; int length = 0;
for (unsigned int i = 0; i < word.length(); i++) { for (unsigned int j = 0; j < word.length(); j++) {
if (word[i] == hide_char) { if (word[j] == hide_char) {
length++; length++;
} }
} }

View File

@ -504,13 +504,6 @@ Local<Object> V8Instance::wrap_role(DiscordObjects::Role *role) {
} }
void V8Instance::js_get_role(Local<Name> property, const PropertyCallbackInfo<Value> &info) { void V8Instance::js_get_role(Local<Name> property, const PropertyCallbackInfo<Value> &info) {
void *self_v = info.Data().As<External>()->Value();
if (!self_v) {
Logger::write("[v8] [js_get_role] Class pointer empty", Logger::LogLevel::Warning);
return;
}
V8Instance *self = static_cast<V8Instance *>(self_v);
void *role_v = info.Holder()->GetInternalField(0).As<External>()->Value(); void *role_v = info.Holder()->GetInternalField(0).As<External>()->Value();
if (!role_v) { if (!role_v) {
Logger::write("[v8] [js_get_role] Role pointer empty", Logger::LogLevel::Warning); Logger::write("[v8] [js_get_role] Role pointer empty", Logger::LogLevel::Warning);

View File

@ -16,17 +16,8 @@
/ Hideous code, but only needs to be run one time. / Hideous code, but only needs to be run one time.
**/ **/
static int callback(void *x, int argc, char **argv, char **azColName) {
int i;
for (i = 0; i<argc; i++) {
std::cout << azColName[i] << " = " << (argv[i] ? argv[i] : "NULL") << std::endl;
}
return 0;
}
int load_questions() { int load_questions() {
sqlite3 *db; sqlite3 *db;
char *zErrMsg = 0;
int rc; int rc;
rc = sqlite3_open("bot/db/trivia.db", &db); rc = sqlite3_open("bot/db/trivia.db", &db);