4b825dc642cb6eb9a060e54bf8d69288fbee490494a6641b73026d662261604d7d192beae70b11dc
 
 
1
#include "files.h"
 
 
2
#include "system.h"
 
 
3
#include "prototyp.h"
 
 
4
#include "stratdef.h"
 
 
5
#include "userprofile.h"
 
 
6
#include "particle.h"
 
 
7
 
 
 
8
struct AVP_USER_PROFILE UserProfile;
 
 
9
 
 
 
10
static const AvP_GameStats_Stored DefaultLevelGameStats =
 
 
11
{
 
 
12
    {0,0,0,0,0,0,0,0,0,0},
 
 
13
    {0,0,0,0,0,0,0,0,0,0},
 
 
14
    {0,0,0,0,0,0,0,0,0,0},
 
 
15
    {0,0,0,0,0,0,0,0,0,0},
 
 
16
    10000,
 
 
17
    0,
 
 
18
    100,
 
 
19
    FIXED_MINUTE,
 
 
20
    60,
 
 
21
    48,
 
 
22
    0,
 
 
23
    0,
 
 
24
    12,
 
 
25
    999,
 
 
26
    999,
 
 
27
    0,
 
 
28
    999,
 
 
29
    0
 
 
30
};
 
 
31
 
 
 
32
extern int GlobalLevelOfDetail_Hierarchical;
 
 
33
struct DETAIL_LEVELS LocalDetailLevels;
 
 
34
 
 
 
35
void SetDetailLevelsFromMenu()
 
 
36
{
 
 
37
    switch (UserProfile.GameOptions.CharacterComplexity)
 
 
38
    {
 
 
39
        default:
 
 
40
        case 0:
 
 
41
            GlobalLevelOfDetail_Hierarchical = ONE_FIXED * 128;
 
 
42
        break;
 
 
43
        case 1:
 
 
44
            GlobalLevelOfDetail_Hierarchical = ONE_FIXED * 4;
 
 
45
        break;
 
 
46
        case 2:
 
 
47
            GlobalLevelOfDetail_Hierarchical = ONE_FIXED * 2;
 
 
48
        break;
 
 
49
        case 3:
 
 
50
            GlobalLevelOfDetail_Hierarchical = ONE_FIXED;
 
 
51
    }
 
 
52
 
 
 
53
    if(UserProfile.GameOptions.BloodParticles < MAX_NO_OF_BLOOD_PARTICLES/4)
 
 
54
        AvP.Difficulty = I_Easy;
 
 
55
 
 
 
56
    if(UserProfile.GameOptions.ParticleComplexity)
 
 
57
    {
 
 
58
        LocalDetailLevels.AlienEnergyViewThreshold = 0;
 
 
59
        LocalDetailLevels.NumberOfSmokeParticlesFromLargeExplosion = 10;
 
 
60
        LocalDetailLevels.NumberOfSmokeParticlesFromSmallExplosion = 5;
 
 
61
        LocalDetailLevels.GhostFlameThrowerCollisions =  1;
 
 
62
    }
 
 
63
    else
 
 
64
    {
 
 
65
        LocalDetailLevels.AlienEnergyViewThreshold = 300;
 
 
66
        LocalDetailLevels.NumberOfSmokeParticlesFromLargeExplosion = 5;
 
 
67
        LocalDetailLevels.NumberOfSmokeParticlesFromSmallExplosion = 2;
 
 
68
        LocalDetailLevels.GhostFlameThrowerCollisions = 0;
 
 
69
    }
 
 
70
}
 
 
71
 
 
 
72
static void SetDefaultProfileOptions()
 
 
73
{
 
 
74
    int a;
 
 
75
    int b;
 
 
76
    strcpy(UserProfile.PlayerName, "DeadMeat");
 
 
77
 
 
 
78
    UserProfile.GammaSetting = 128;
 
 
79
    UserProfile.MarineInputPrimaryConfig = DefaultMarineInputPrimaryConfig;
 
 
80
    UserProfile.MarineInputSecondaryConfig = DefaultMarineInputSecondaryConfig;
 
 
81
    UserProfile.PredatorInputPrimaryConfig = DefaultPredatorInputPrimaryConfig;
 
 
82
    UserProfile.PredatorInputSecondaryConfig = DefaultPredatorInputSecondaryConfig;
 
 
83
    UserProfile.AlienInputPrimaryConfig = DefaultAlienInputPrimaryConfig;
 
 
84
    UserProfile.AlienInputSecondaryConfig = DefaultAlienInputSecondaryConfig;
 
 
85
 
 
 
86
    UserProfile.EffectsSoundVolume = VOLUME_DEFAULT;
 
 
87
    UserProfile.grabmouse = 0;
 
 
88
    UserProfile.AutoWeaponChangeOn = 1;
 
 
89
    UserProfile.fullscreen = 0;
 
 
90
    UserProfile.music_volume = 127;
 
 
91
    UserProfile.screen.height = UserProfile.screen.width = -1;
 
 
92
    UserProfile.loadsounds = 0;
 
 
93
    UserProfile.active_bonus = CHEATMODE_NONACTIVE;
 
 
94
 
 
 
95
    UserProfile.GameOptions.NumberOfDecals = MAX_NO_OF_DECALS / 2;
 
 
96
    UserProfile.GameOptions.LightCoronas = 1;
 
 
97
    UserProfile.GameOptions.MapPrelighting = 0;
 
 
98
    UserProfile.GameOptions.AllLightsDestructable = 0; 
 
 
99
    UserProfile.GameOptions.BloodCollidesWithEnvironment = 1; 
 
 
100
    UserProfile.GameOptions.DecalsOnCharacters = 1;
 
 
101
    UserProfile.GameOptions.CharacterComplexity = 3;
 
 
102
    UserProfile.GameOptions.ParticleComplexity = 1;
 
 
103
    UserProfile.GameOptions.NoneBloodParticles = MAX_NO_OF_PARTICLES;
 
 
104
    UserProfile.GameOptions.BloodParticles = MAX_NO_OF_BLOOD_PARTICLES/4;
 
 
105
 
 
 
106
    SetDetailLevelsFromMenu();
 
 
107
 
 
 
108
    for (a=0; a < I_MaxDifficulties; a++) 
 
 
109
    {
 
 
110
        for (b=0; b < AVP_ENVIRONMENT_END_OF_LIST; b++) 
 
 
111
            UserProfile.PersonalBests[a][b] = DefaultLevelGameStats;
 
 
112
 
 
 
113
        for(b=0; b < 12; b++)
 
 
114
            UserProfile.LevelCompleted[a].Difficulty[b] = Not_Completed;
 
 
115
    }
 
 
116
 
 
 
117
    for (a=0; a < MAX_NUMBER_OF_CHEATMODES; a++) 
 
 
118
        UserProfile.CheatMode[a] = 0;
 
 
119
}
 
 
120
 
 
 
121
void LoadUserProfile()
 
 
122
{
 
 
123
    FILE * profile_file = OpenGameFile("profile.prf", 1, FILETYPE_CONFIG);
 
 
124
 
 
 
125
    if ((NULL == profile_file) || (fread(&UserProfile, 1, sizeof(struct AVP_USER_PROFILE), profile_file) != sizeof(struct AVP_USER_PROFILE)))
 
 
126
    {
 
 
127
        SetDefaultProfileOptions();
 
 
128
    }
 
 
129
    else
 
 
130
    {
 
 
131
        SetDetailLevelsFromMenu();
 
 
132
        fclose(profile_file);
 
 
133
    }
 
 
134
}
 
 
135
 
 
 
136
int SaveUserProfile()
 
 
137
{
 
 
138
    FILE* file = OpenGameFile("profile.prf", 0, FILETYPE_CONFIG);
 
 
139
 
 
 
140
    if (NULL != file)
 
 
141
    {
 
 
142
        fwrite(&UserProfile, sizeof(struct AVP_USER_PROFILE), 1, file);
 
 
143
        fclose(file);
 
 
144
        return 1;
 
 
145
    }
 
 
146
 
 
 
147
return 0;
 
 
148
}