diff --git a/privatebet/config.c b/privatebet/config.c index 68178fca..90eb512c 100644 --- a/privatebet/config.c +++ b/privatebet/config.c @@ -371,13 +371,14 @@ int32_t bet_parse_verus_player() sizeof(player_config.verus_pid)); } //Check if all IDs are valid - if((!player_config.dealer_id) || (!player_config.table_id) || (!player_config.verus_pid) || !is_id_exists(player_config.dealer_id,0) || !is_id_exists(player_config.table_id,0)) { + if ((!player_config.dealer_id) || (!player_config.table_id) || (!player_config.verus_pid) || + !is_id_exists(player_config.dealer_id, 0) || !is_id_exists(player_config.table_id, 0)) { return ERR_CONFIG_PLAYER_ARGS; } //Check if the node has player IDs priv keys - if(!id_cansignfor(player_config.verus_pid,0,&retval)) { + if (!id_cansignfor(player_config.verus_pid, 0, &retval)) { return retval; } - + return retval; } diff --git a/privatebet/dealer.c b/privatebet/dealer.c index 7918375b..e466ecf6 100644 --- a/privatebet/dealer.c +++ b/privatebet/dealer.c @@ -109,7 +109,9 @@ int32_t dealer_table_init(struct table t) return ERR_ID_NOT_FOUND; game_state = get_game_state(t.table_id); - if (game_state == G_ZEROIZED_STATE) { + + switch (game_state) { + case G_ZEROIZED_STATE: game_id = rand256(0); dlg_info("Updating %s key...", T_GAME_ID_KEY); out = append_cmm_from_id_key_data_hex(t.table_id, T_GAME_ID_KEY, bits256_str(hexstr, game_id), false); @@ -122,7 +124,8 @@ int32_t dealer_table_init(struct table t) if (!out) return ERR_GAME_STATE_UPDATE; dlg_info("%s", cJSON_Print(out)); - + // No break is intentional + case G_TABLE_ACTIVE: dlg_info("Updating %s key...", T_TABLE_INFO_KEY); out = append_cmm_from_id_key_data_cJSON( t.table_id, get_key_data_vdxf_id(T_TABLE_INFO_KEY, bits256_str(hexstr, game_id)), @@ -136,7 +139,8 @@ int32_t dealer_table_init(struct table t) if (!out) return ERR_GAME_STATE_UPDATE; dlg_info("%s", cJSON_Print(out)); - } else { + break; + default: dlg_info("Table is in game, at state ::%s", game_state_str(game_state)); } return retval; @@ -313,11 +317,10 @@ int32_t dealer_init(struct table t) } } - game_state = get_game_state(t.table_id); - if (game_state == G_ZEROIZED_STATE) { - retval = dealer_table_init(t); - if (retval) - return retval; + retval = dealer_table_init(t); + if (retval != OK) { + dlg_info("Table Init is failed"); + return retval; } while (1) { diff --git a/privatebet/err.h b/privatebet/err.h index 2c5cdfc3..da35edd0 100644 --- a/privatebet/err.h +++ b/privatebet/err.h @@ -128,7 +128,6 @@ All the errors that come across in bet are defined here. The error numbers are a #define ERR_NULL_ID 141 #define ERR_TABLE_UNREGISTERED 142 - // clang-format on const char *bet_err_str(int32_t err_no); #endif