Permalink
Browse files

Various bug fixes

  • Loading branch information...
ThorConzales ThorConzales
ThorConzales authored and ThorConzales committed Aug 27, 2017
1 parent 6167865 commit 06e7fdf423aa66d1e4f4ff602302b57f3195bfa9
@@ -64,7 +64,7 @@ public class LobbyController : Controller, IDisposable {
NegativeReputation = p.User.NegativeReputation
} : null,
GameStats = p.User != null ? UserUtils.GetGameStats(p.GamesStartedRM, p.GamesStartedDM, p.GamesWonRM, p.GamesWonDM, p.GamesEndedRM, p.GamesEndedDM) : null,
})
}).ToList()
};
foreach (var player in lobby.Players) {
LobbyUtils.CalculateUserFieldColors(player, lobby.Ranked);
@@ -20,8 +20,8 @@ public class UserProfileController : IDisposable {
_repository = repository;
}
[HttpGet("{id}/{lobbyId}")]
public User Get(string id, string lobbyId) {
[HttpGet("{id}")]
public User Get(string id) {
var user = _repository.Users.Include(u => u.LobbySlots).Include(u => u.Reputations).ThenInclude(ur => ur.Reputation).Include(u => u.Reputations).ThenInclude(u => u.Lobby).Select(u => new User {
Id = u.Id,
SSteamId = u.SteamId.ToString(),
@@ -61,10 +61,8 @@ public class UserProfileController : IDisposable {
} : null
}).ToList()
}).FirstOrDefault(u => u.SSteamId == id);
user.GameStats = UserUtils.GetGameStats(user.GamesStartedRM, user.GamesStartedDM, user.GamesWonRM, user.GamesWonRM, user.GamesEndedRM, user.GamesEndedDM);
var longLobbyId = ulong.Parse(lobbyId);
var lobby = _repository.Lobbies.FirstOrDefault(l => l.LobbyId == longLobbyId);
LobbyUtils.CalculateUserFieldColors(user, lobby.Ranked);
user.GameStats = UserUtils.GetGameStats(user.GamesStartedRM, user.GamesStartedDM, user.GamesWonRM, user.GamesWonDM, user.GamesEndedRM, user.GamesEndedDM);
LobbyUtils.CalculateUserFieldColors(user, 0);
return user;
}
@@ -113,11 +113,39 @@ public class NetHookDumpReaderJob {
private void ProcessCreateLobbyResponse(NetHookItem item) {
var msg = item.ReadAsProtobufMsg<CMsgClientMMSCreateLobbyResponse>();
Variables.Lobby.LobbyId = msg.Body.steam_id_lobby;
CheckIfReJoiningStartedLobby();
}
private void ProcessJoinLobbyResponse(NetHookItem item) {
var msg = item.ReadAsProtobufMsg<CMsgClientMMSJoinLobbyResponse>();
Variables.Lobby.LobbyId = msg.Body.steam_id_lobby;
CheckIfReJoiningStartedLobby();
}
private void CheckIfReJoiningStartedLobby() {
try {
using (IRepository repository = new Repository()) {
var lobby = repository.Lobbies.Include(l => l.Players).ThenInclude(p => p.User).FirstOrDefault(l => l.LobbyId == Variables.Lobby.LobbyId && l.Started.HasValue);
if (lobby != null) {
lobby.Joined = DateTime.UtcNow;
lobby.Started = null;
lobby.Sealed = false;
repository.SetModified(lobby);
repository.SaveChanges();
foreach (var player in lobby.Players.Where(p => p.Position > 0 && p.User != null)) {
try {
player.User.Games--;
repository.SetModified(player.User);
repository.SaveChanges();
} catch (Exception e) {
LogUtils.Error("Error while modifing user for re-joined lobby: "+player.User.Name, e);
}
}
}
}
} catch (Exception e) {
LogUtils.Error("Error while checking if re-joining started lobby", e);
}
}
private void ProcessLeaderBoardUpdate(NetHookItem item) {
@@ -51,7 +51,8 @@ public class Startup {
app.UseMvc();
if (Variables.ReplayMode) {
Variables.NethookDumpDir = @"C:\Program Files (x86)\Steam\nethook\_Aoe2HostLobby2";
//Variables.NethookDumpDir = @"C:\Program Files (x86)\Steam\nethook\_Aoe2HostLobby2";
Variables.NethookDumpDir = @"C:\Program Files (x86)\Steam\nethook\_Aoe2JoinLobby";
} else {
_netHookDumpReaderJob = new NetHookDumpReaderJob();
}
@@ -212,7 +212,7 @@ public class UserUtils {
throw new Exception("User not found in database");
}
player.ReputationStats = new PlayerReputationStats() {
Games = 0,
Games = user.Games,
PositiveReputation = user.PositiveReputation,
NegativeReputation = user.NegativeReputation
};
@@ -34,6 +34,7 @@ export class RunningSessionPageComponent implements OnInit, OnDestroy {
this.startLobbyFetcherTimer();
if (this.lobbyId == "0") {
this.subscriptions.push(this.appService.Events.gameStarted.subscribe(() => {
this.lobbyId = this.lobby.sLobbyId;
this.lobbyStarted = true;
this.appService.stopNethook(() => { });
this.appService.toastInfo("Lobby started!");
@@ -12,7 +12,7 @@
<span style="margin-right: 10px;">Location <strong>{{profile.location}}</strong></span>
</td>
<td>
<span style="margin-right: 10px;" [ngClass]="{cellColorSafe: profile.fieldColors?.Games == 1, cellColorDanger: profile.fieldColors?.Games == 2}">Shared Games <strong>{{profile.games}}</strong></span>
<span style="margin-right: 10px;">Shared Games <span [ngClass]="{cellColorSafe: profile.fieldColors?.Games == 1, cellColorDanger: profile.fieldColors?.Games == 2}" style="font-weight: bold;">{{profile.games}}</span></span>
</td>
<td>
<i class="material-icons md-24" style="margin-right: 5px; margin-top: 7px; color: red;">thumb_down</i>
@@ -55,7 +55,7 @@ export class UserProfileDialogComponent implements OnInit {
}
private fetchProfile() {
this.httpService.get<UserProfile>("/api/userProfile/" + this.data.steamId + "/" + this.data.lobbyId).subscribe(response => {
this.httpService.get<UserProfile>("/api/userProfile/" + this.data.steamId).subscribe(response => {
this.profile = response;
this.userReputationsDataSource = new UserReputationsDataSource(response.reputations);
if (this.profile.knownNames.length > 1) {
@@ -71,7 +71,11 @@ public class Repository : DbContext, IRepository {
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
var path = Path.Combine(Environment.GetEnvironmentVariable("AppData"), "AoE2HDLobbyCompanion\\database.db");
var databaseName = "AoE2HDLobbyCompanion\\database.db";
#if DEBUG
databaseName = "AoE2HDLobbyCompanion\\database_test.db";
#endif
var path = Path.Combine(Environment.GetEnvironmentVariable("AppData"), databaseName);
optionsBuilder.UseSqlite("Data Source=" + path);
}
}

0 comments on commit 06e7fdf

Please sign in to comment.