Many new settings to support the new state machine functionality.
This commit is contained in:
parent
583995097a
commit
998f93134a
5 changed files with 90 additions and 28 deletions
|
@ -19,6 +19,7 @@
|
|||
* file in the root of this repository. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <SystemK.h>
|
||||
#include <NVM.h>
|
||||
|
||||
|
@ -27,6 +28,8 @@ static const uint8_t UNINTIALIZED_UINT8 = UINT8_MAX;
|
|||
static uint8_t Cached_Team_ID = UNINTIALIZED_UINT8;
|
||||
static uint8_t Cached_Player_ID = UNINTIALIZED_UINT8;
|
||||
static uint8_t Cached_Weapon_ID = UNINTIALIZED_UINT8;
|
||||
static uint8_t Cached_Max_Health = UNINTIALIZED_UINT8;
|
||||
static uint8_t Cached_N_Special_Weapons_On_Reentry = UNINTIALIZED_UINT8;
|
||||
|
||||
SystemKResult_T SETTINGS_get_uint8_t(SystemKSettingID_T id, uint8_t *value)
|
||||
{
|
||||
|
@ -55,7 +58,6 @@ SystemKResult_T SETTINGS_get_uint8_t(SystemKSettingID_T id, uint8_t *value)
|
|||
key = "Team_ID";
|
||||
cached_value = &Cached_Team_ID;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SYSTEMK_SETTING_PLAYERID:
|
||||
|
@ -84,6 +86,32 @@ SystemKResult_T SETTINGS_get_uint8_t(SystemKSettingID_T id, uint8_t *value)
|
|||
}
|
||||
break;
|
||||
|
||||
case SYSTEMK_SETTING_MAX_HEALTH:
|
||||
if (Cached_Max_Health != UNINTIALIZED_UINT8)
|
||||
{
|
||||
*value = Cached_Max_Health;
|
||||
result = SYSTEMK_RESULT_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = "Max_Health";
|
||||
cached_value = &Cached_Max_Health;
|
||||
}
|
||||
break;
|
||||
|
||||
case SYSTEMK_SETTING_N_SPECIAL_WEAPONS_ON_REENTRY:
|
||||
if (Cached_N_Special_Weapons_On_Reentry != UNINTIALIZED_UINT8)
|
||||
{
|
||||
*value = Cached_N_Special_Weapons_On_Reentry;
|
||||
result = SYSTEMK_RESULT_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = "N_Special_Weapons_On_Reentry";
|
||||
cached_value = &Cached_N_Special_Weapons_On_Reentry;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
result = SYSTEMK_RESULT_WRONG_DATATYPE;
|
||||
break;
|
||||
|
@ -142,6 +170,16 @@ SystemKResult_T SETTINGS_set_uint8_t(SystemKSettingID_T id, uint8_t value)
|
|||
result = KV_Set_Value_uint8(CONFIG_FILE, "Weapon_ID", &value);
|
||||
break;
|
||||
|
||||
case SYSTEMK_SETTING_MAX_HEALTH:
|
||||
Cached_Max_Health = value;
|
||||
result = KV_Set_Value_uint8(CONFIG_FILE, "Max_Health", &value);
|
||||
break;
|
||||
|
||||
case SYSTEMK_SETTING_N_SPECIAL_WEAPONS_ON_REENTRY:
|
||||
Cached_N_Special_Weapons_On_Reentry = value;
|
||||
result = KV_Set_Value_uint8(CONFIG_FILE, "N_Special_Weapons_On_Reentry", &value);
|
||||
break;
|
||||
|
||||
default:
|
||||
result = SYSTEMK_RESULT_WRONG_DATATYPE;
|
||||
break;
|
||||
|
@ -166,6 +204,10 @@ SystemKResult_T SETTINGS_get_uint32_t(SystemKSettingID_T id, uint32_t *value)
|
|||
key = "T_Start_Game_in_ms";
|
||||
break;
|
||||
|
||||
case SYSTEMK_SETTING_T_GAME_LENGTH_in_ms:
|
||||
key = "T_Game_Length_in_ms";
|
||||
break;
|
||||
|
||||
default:
|
||||
result = SYSTEMK_RESULT_WRONG_DATATYPE;
|
||||
break;
|
||||
|
@ -199,6 +241,10 @@ SystemKResult_T SETTINGS_set_uint32_t(SystemKSettingID_T id, uint32_t value)
|
|||
result = KV_Set_Value_uint32(CONFIG_FILE, "T_Start_Game_in_ms", &value);
|
||||
break;
|
||||
|
||||
case SYSTEMK_SETTING_T_GAME_LENGTH_in_ms:
|
||||
result = KV_Set_Value_uint32(CONFIG_FILE, "T_Game_Length_in_ms", &value);
|
||||
break;
|
||||
|
||||
default:
|
||||
result = SYSTEMK_RESULT_WRONG_DATATYPE;
|
||||
break;
|
||||
|
@ -209,13 +255,21 @@ SystemKResult_T SETTINGS_set_uint32_t(SystemKSettingID_T id, uint32_t value)
|
|||
|
||||
SystemKResult_T SETTINGS_get_device_name(char* name)
|
||||
{
|
||||
SystemKResult_T result = SYSTEMK_RESULT_NOT_IMPLEMENTED;
|
||||
char buffer[KV_MAX_VALUE_LENGTH];
|
||||
SystemKResult_T result = KV_Get_Value_string(CONFIG_FILE, "Device_Name", buffer);
|
||||
|
||||
if (result == SYSTEMK_RESULT_SUCCESS)
|
||||
{
|
||||
memcpy(name, buffer, SYSTEMK_MAX_CHARS_IN_DEVICE_NAME);
|
||||
buffer[SYSTEMK_MAX_CHARS_IN_DEVICE_NAME] = 0x00;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SystemKResult_T SETTINGS_set_device_name(char* name)
|
||||
{
|
||||
SystemKResult_T result = SYSTEMK_RESULT_NOT_IMPLEMENTED;
|
||||
SystemKResult_T result = KV_Set_Value_string(CONFIG_FILE, "Device_Name", name);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue