@@ -137,18 +137,30 @@ func (b bf2CmdBuilder) GetArgs(fr game_launcher.FileRepository, u *url.URL, laun
137
137
return nil , err
138
138
}
139
139
140
- playerName , encryptedPassword , err := bf2 .GetEncryptedLogin (profileCon )
141
- if err != nil {
142
- return nil , fmt .Errorf ("failed to extract login details from profile.con: %s" , err )
143
- }
140
+ args := make ([]string , 0 , 12 )
141
+ // Only multiplayer profiles contain an email address
142
+ if profileCon .HasKey (bf2 .ProfileConKeyEmail ) {
143
+ playerName , encryptedPassword , err2 := bf2 .GetEncryptedLogin (profileCon )
144
+ if err2 != nil {
145
+ return nil , fmt .Errorf ("failed to extract login details from profile.con: %s" , err )
146
+ }
144
147
145
- password , err := bf2 .DecryptProfileConPassword (encryptedPassword )
146
- if err != nil {
147
- return nil , err
148
+ password , err2 := bf2 .DecryptProfileConPassword (encryptedPassword )
149
+ if err2 != nil {
150
+ return nil , fmt .Errorf ("failed to decrypt player password: %s" , err )
151
+ }
152
+
153
+ args = append (args , "+playerName" , playerName , "+playerPassword" , password )
154
+ } else {
155
+ // Singleplayer profiles always have an empty GamespyNick, so use the "normal" nick instead
156
+ playerName , err2 := profileCon .GetValue (bf2 .ProfileConKeyNick )
157
+ if err2 != nil {
158
+ return nil , fmt .Errorf ("failed to extract player name from profile.con: %s" , err2 )
159
+ }
160
+
161
+ args = append (args , "+playerName" , playerName .String ())
148
162
}
149
163
150
- args := make ([]string , 0 , 12 )
151
- args = append (args , "+playerName" , playerName , "+playerPassword" , password )
152
164
if launchType == game_launcher .LaunchTypeLaunchAndJoin {
153
165
args = append (args , "+joinServer" , u .Hostname (), "+port" , u .Port ())
154
166
}
0 commit comments