00001
00002 #include "revolt.h"
00003 #include "registry.h"
00004
00005
00006
00007 REGISTRY_SETTINGS RegistrySettings;
00008
00010
00012
00013 void GetRegistrySettings(void)
00014 {
00015 long r;
00016 HKEY key;
00017 DWORD size, flag;
00018
00019
00020
00021 RegistrySettings.EnvFlag = TRUE;
00022 RegistrySettings.MirrorFlag = TRUE;
00023 RegistrySettings.AutoBrake = FALSE;
00024 RegistrySettings.ShadowFlag = TRUE;
00025
00026 RegistrySettings.LightFlag = TRUE;
00027 RegistrySettings.InstanceFlag = TRUE;
00028 RegistrySettings.SkidFlag = TRUE;
00029 RegistrySettings.CarID = 0;
00030
00031 RegistrySettings.ScreenWidth = 640;
00032 RegistrySettings.ScreenHeight = 480;
00033 RegistrySettings.ScreenBpp = 16;
00034 RegistrySettings.DrawDevice = 0;
00035
00036 RegistrySettings.Brightness = 256;
00037 RegistrySettings.Contrast = 256;
00038 RegistrySettings.TextureBpp = 16;
00039
00040 size = MAX_PLAYER_NAME;
00041 GetUserName(RegistrySettings.PlayerName, &size);
00042
00043 wsprintf(RegistrySettings.LevelDir, "MUSE1");
00044
00045
00046
00047 r = RegCreateKeyEx(REGISTRY_ROOT, REGISTRY_KEY, 0, "Revolt", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key, &flag);
00048 if (r != ERROR_SUCCESS) return;
00049
00050
00051
00052 GET_REGISTRY_VALUE(key, "EnvFlag", &RegistrySettings.EnvFlag, 4);
00053 GET_REGISTRY_VALUE(key, "MirrorFlag", &RegistrySettings.MirrorFlag, 4);
00054 GET_REGISTRY_VALUE(key, "AutoBrake", &RegistrySettings.AutoBrake, 4);
00055 GET_REGISTRY_VALUE(key, "ShadowFlag", &RegistrySettings.ShadowFlag, 4);
00056
00057 GET_REGISTRY_VALUE(key, "LightFlag", &RegistrySettings.LightFlag, 4);
00058 GET_REGISTRY_VALUE(key, "InstanceFlag", &RegistrySettings.InstanceFlag, 4);
00059 GET_REGISTRY_VALUE(key, "SkidFlag", &RegistrySettings.SkidFlag, 4);
00060 GET_REGISTRY_VALUE(key, "CarID", &RegistrySettings.CarID, 4);
00061
00062 GET_REGISTRY_VALUE(key, "ScreenWidth", &RegistrySettings.ScreenWidth, 4);
00063 GET_REGISTRY_VALUE(key, "ScreenHeight", &RegistrySettings.ScreenHeight, 4);
00064 GET_REGISTRY_VALUE(key, "ScreenBpp", &RegistrySettings.ScreenBpp, 4);
00065 GET_REGISTRY_VALUE(key, "DrawDevice", &RegistrySettings.DrawDevice, 4);
00066
00067 GET_REGISTRY_VALUE(key, "Brightness", &RegistrySettings.Brightness, 4);
00068 GET_REGISTRY_VALUE(key, "Contrast", &RegistrySettings.Contrast, 4);
00069 GET_REGISTRY_VALUE(key, "TextureBpp", &RegistrySettings.TextureBpp, 4);
00070
00071 GET_REGISTRY_VALUE(key, "PlayerName", RegistrySettings.PlayerName, MAX_PLAYER_NAME);
00072 GET_REGISTRY_VALUE(key, "LevelDir", RegistrySettings.LevelDir, MAX_LEVEL_DIR_NAME);
00073
00074 RenderSettings.Env = RegistrySettings.EnvFlag;
00075 RenderSettings.Mirror = RegistrySettings.MirrorFlag;
00076 GameSettings.AutoBrake = RegistrySettings.AutoBrake;
00077 RenderSettings.Shadow = RegistrySettings.ShadowFlag;
00078
00079 RenderSettings.Light = RegistrySettings.LightFlag;
00080 RenderSettings.Instance = RegistrySettings.InstanceFlag;
00081 RenderSettings.Skid = RegistrySettings.SkidFlag;
00082 GameSettings.CarID = RegistrySettings.CarID;
00083
00084
00085
00086 #if REGISTRY_SECURITY_CHECK
00087 flag = 0;
00088 GET_REGISTRY_VALUE(key, "WindowType", &flag, 4);
00089 if (!flag)
00090 {
00091 Box(NULL, "Illegal copy of Revolt!", MB_OK);
00092 QuitGame = TRUE;
00093 return;
00094 }
00095 #endif
00096
00097
00098
00099 RegCloseKey(key);
00100 }
00101
00103
00105
00106 void SetRegistrySettings(void)
00107 {
00108 long r;
00109 HKEY key;
00110
00111
00112
00113 r = RegOpenKeyEx(REGISTRY_ROOT, REGISTRY_KEY, 0, KEY_ALL_ACCESS, &key);
00114 if (r != ERROR_SUCCESS) return;
00115
00116
00117
00118 RegistrySettings.EnvFlag = RenderSettings.Env;
00119 RegistrySettings.MirrorFlag = RenderSettings.Mirror;
00120 RegistrySettings.AutoBrake = GameSettings.AutoBrake;
00121 RegistrySettings.ShadowFlag = RenderSettings.Shadow;
00122
00123 RegistrySettings.LightFlag = RenderSettings.Light;
00124 RegistrySettings.InstanceFlag = RenderSettings.Instance;
00125 RegistrySettings.SkidFlag = RenderSettings.Skid;
00126 RegistrySettings.CarID = GameSettings.CarID;
00127
00128 SET_REGISTRY_VALUE(key, "EnvFlag", REG_DWORD, &RegistrySettings.EnvFlag, 4);
00129 SET_REGISTRY_VALUE(key, "MirrorFlag", REG_DWORD, &RegistrySettings.MirrorFlag, 4);
00130 SET_REGISTRY_VALUE(key, "AutoBrake", REG_DWORD, &RegistrySettings.AutoBrake, 4);
00131 SET_REGISTRY_VALUE(key, "ShadowFlag", REG_DWORD, &RegistrySettings.ShadowFlag, 4);
00132
00133 SET_REGISTRY_VALUE(key, "LightFlag", REG_DWORD, &RegistrySettings.LightFlag, 4);
00134 SET_REGISTRY_VALUE(key, "InstanceFlag", REG_DWORD, &RegistrySettings.InstanceFlag, 4);
00135 SET_REGISTRY_VALUE(key, "SkidFlag", REG_DWORD, &RegistrySettings.SkidFlag, 4);
00136 SET_REGISTRY_VALUE(key, "CarID", REG_DWORD, &RegistrySettings.CarID, 4);
00137
00138 SET_REGISTRY_VALUE(key, "ScreenWidth", REG_DWORD, &RegistrySettings.ScreenWidth, 4);
00139 SET_REGISTRY_VALUE(key, "ScreenHeight", REG_DWORD, &RegistrySettings.ScreenHeight, 4);
00140 SET_REGISTRY_VALUE(key, "ScreenBpp", REG_DWORD, &RegistrySettings.ScreenBpp, 4);
00141 SET_REGISTRY_VALUE(key, "DrawDevice", REG_DWORD, &RegistrySettings.DrawDevice, 4);
00142
00143 SET_REGISTRY_VALUE(key, "Brightness", REG_DWORD, &RegistrySettings.Brightness, 4);
00144 SET_REGISTRY_VALUE(key, "Contrast", REG_DWORD, &RegistrySettings.Contrast, 4);
00145 SET_REGISTRY_VALUE(key, "TextureBpp", REG_DWORD, &RegistrySettings.TextureBpp, 4);
00146
00147 SET_REGISTRY_VALUE(key, "PlayerName", REG_SZ, RegistrySettings.PlayerName, MAX_PLAYER_NAME);
00148 SET_REGISTRY_VALUE(key, "LevelDir", REG_SZ, RegistrySettings.LevelDir, MAX_LEVEL_DIR_NAME);
00149
00150
00151
00152 RegCloseKey(key);
00153 }