-
Notifications
You must be signed in to change notification settings - Fork 13
/
Room.cs
93 lines (80 loc) · 2.24 KB
/
Room.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
using System.Collections.Generic;
using System.Collections;
namespace OpenSMO
{
public enum RoomStatus : int { Ready, Closed, Locked }
public class Room
{
public MainClass mainClass;
public bool Fixed = false;
public int[] FixedOperators;
public string FixedMotd;
public string ID = "";
public string Name;
public string Description;
public string Password;
public string Style = "dance";
public RoomStatus Status = RoomStatus.Closed;
public bool Free;
public bool AllPlaying = false;
public bool Secret = false;
public int SendStatsTimer = 0;
public Hashtable Meta = new Hashtable();
public User Owner;
public List<User> Users
{
get
{
List<User> ret = new List<User>();
foreach (User user in mainClass.Users) {
if (user.CurrentRoom == this)
ret.Add(user);
}
return ret;
}
}
public int UserCount { get { return Users.Count; } }
public Song CurrentSong = new Song();
public bool Reported;
private string _ChatBuffer = "";
public string ChatBuffer
{
get
{
string[] lines = this._ChatBuffer.Split('\n');
string ret = "";
int lineLimit = int.Parse(mainClass.ServerConfig.Get("RTS_ChatLines"));
int lineCount = lines.Length;
int startCount = Math.Max(0, lineCount - lineLimit);
for (int i = startCount; i < lineCount; i++)
ret += lines[i] + '\n';
return ret.Trim('\n');
}
}
public void AddChatBuffer(string str)
{
_ChatBuffer += str + "\n";
}
public Room(MainClass mainClass, User Owner)
{
this.mainClass = mainClass;
this.Owner = Owner;
this.ID = MainClass.RandomString(5);
}
public void Update()
{
if (++SendStatsTimer == mainClass.FPS / 2) {
foreach (User user in Users) {
if (user.Playing)
user.SendGameStatus();
}
SendStatsTimer = 0;
}
if (UserCount == 0 && !Fixed) {
MainClass.AddLog("Room '" + Name + "' removed.");
mainClass.Rooms.Remove(this);
}
}
}
}