Today I've had majour problems with GameMakers switch statement being executed. When the HTTP ASYNC EVENT is executed, show_message(answer)
is executed, but the switch statement under it does not.
I think this is a compiler error, because it seems that the string_length of the "answer variable" is 1, and using string_digits to make sure, that it escapes all the possible blankspaces or unnecessary characters that could appear when retrieving http callback.
Only possible returning values of variable answer are: 0, 1, 2, 3, 4.
So here is the code of HTTP ASYNC EVENT:
if(ds_map_find_value(async_load, "id") == request_auth) {
if(ds_map_find_value(async_load, "status") == 0) {
callback = ds_map_find_value(async_load, "result");
var answer = string_digits(callback);
show_message(answer);
switch(answer) {
case USERNAME_EXISTS:
show_message("username already exists");
break;
case ACCOUNT_CREATED:
show_message("Your account has been successfully created!");
break;
case LOGGED_IN:
buffer_seek(global.buffer, buffer_seek_start, 0);
buffer_write(global.buffer, buffer_u8, 0);
buffer_write(global.buffer, buffer_string, "username");
Send();
break;
case INCORRECT_PASSWORD:
show_message("your password is incorrect");
break;
case INCORRECT_USERNAME:
show_message("your username is invalid");
break;
}
}
else {
callback = noone;
}
}