aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Attorney_Online.pro2
m---------base/themes0
-rw-r--r--include/aoapplication.h2
-rw-r--r--include/aolayer.h1
-rw-r--r--src/aolayer.cpp9
-rw-r--r--src/charselect.cpp4
-rw-r--r--src/courtroom.cpp218
-rw-r--r--src/demoserver.cpp49
-rw-r--r--src/packet_distribution.cpp25
-rw-r--r--src/text_file_functions.cpp34
10 files changed, 184 insertions, 160 deletions
diff --git a/Attorney_Online.pro b/Attorney_Online.pro
index ba1c80a..2a5c1e1 100644
--- a/Attorney_Online.pro
+++ b/Attorney_Online.pro
@@ -3,7 +3,7 @@ QT += core gui widgets network
TARGET = Attorney_Online
TEMPLATE = app
-VERSION = 2.9.0.0
+VERSION = 2.9.1.0
INCLUDEPATH += $$PWD/include
DESTDIR = $$PWD/bin
diff --git a/base/themes b/base/themes
-Subproject 126447457906992e0096c4c9416f2b1f7986ff4
+Subproject c9acb90137361ea8c29bc4cf2bf530d14b52b23
diff --git a/include/aoapplication.h b/include/aoapplication.h
index 9fa8c75..493f1c9 100644
--- a/include/aoapplication.h
+++ b/include/aoapplication.h
@@ -511,7 +511,7 @@ public:
private:
const int RELEASE = 2;
const int MAJOR_VERSION = 9;
- const int MINOR_VERSION = 0;
+ const int MINOR_VERSION = 1;
QVector<server_type> server_list;
QVector<server_type> favorite_list;
diff --git a/include/aolayer.h b/include/aolayer.h
index 1984b77..f42642c 100644
--- a/include/aolayer.h
+++ b/include/aolayer.h
@@ -52,6 +52,7 @@ public:
bool force_continuous = false;
Qt::TransformationMode transform_mode = Qt::FastTransformation; // transformation mode to use for this image
bool stretch = false; // Should we stretch/squash this image to fill the screen?
+ bool masked = true; // Set a mask to the dimensions of the widget?
// Set the movie's image to provided paths, preparing for playback.
void start_playback(QString p_image);
diff --git a/src/aolayer.cpp b/src/aolayer.cpp
index f0d5779..e4db75a 100644
--- a/src/aolayer.cpp
+++ b/src/aolayer.cpp
@@ -98,9 +98,10 @@ void AOLayer::center_pixmap(QPixmap f_pixmap) {
x + (f_w - f_pixmap.width()) / 2,
y + (f_h - f_pixmap.height())); // Always center horizontally, always put
// at the bottom vertically
- this->setMask(
- QRegion((f_pixmap.width() - f_w) / 2, (f_pixmap.height() - f_h) / 2, f_w,
- f_h)); // make sure we don't escape the area we've been given
+ if (masked)
+ this->setMask(
+ QRegion((f_pixmap.width() - f_w) / 2, (f_pixmap.height() - f_h) / 2, f_w,
+ f_h)); // make sure we don't escape the area we've been given
}
void AOLayer::combo_resize(int w, int h)
@@ -156,7 +157,7 @@ void CharLayer::load_image(QString p_filename, QString p_charname,
transform_mode = ao_app->get_scaling(
ao_app->get_emote_property(p_charname, p_filename, "scaling"));
stretch = ao_app->get_emote_property(p_charname, p_filename, "stretch")
- .startsWith(true);
+ .startsWith("true");
if ((p_charname == last_char) &&
((p_filename == last_emote) ||
(p_filename.mid(3, -1) == last_emote.mid(3, -1))) &&
diff --git a/src/charselect.cpp b/src/charselect.cpp
index 0a2659e..820abf5 100644
--- a/src/charselect.cpp
+++ b/src/charselect.cpp
@@ -164,14 +164,14 @@ void Courtroom::char_clicked(int n_char)
}
}
- if (n_char != m_cid) {
+ if (n_char != m_cid || n_char == -1) {
ao_app->send_server_packet(
new AOPacket("PW#" + ui_char_password->text() + "#%"));
ao_app->send_server_packet(
new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" +
QString::number(n_char) + "#" + get_hdid() + "#%"));
}
- else {
+ if (n_char == m_cid || n_char == -1) {
update_character(n_char);
enter_courtroom();
set_courtroom_size();
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index 507acc1..8a346a2 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -46,7 +46,9 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_vp_background = new BackgroundLayer(ui_viewport, ao_app);
ui_vp_speedlines = new SplashLayer(ui_viewport, ao_app);
ui_vp_player_char = new CharLayer(ui_viewport, ao_app);
+ ui_vp_player_char->masked = false;
ui_vp_sideplayer_char = new CharLayer(ui_viewport, ao_app);
+ ui_vp_sideplayer_char->masked = false;
ui_vp_sideplayer_char->hide();
ui_vp_desk = new BackgroundLayer(ui_viewport, ao_app);
@@ -171,17 +173,21 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
initialize_emotes();
ui_pos_dropdown = new QComboBox(this);
+ ui_pos_dropdown->view()->setTextElideMode(Qt::ElideLeft);
ui_pos_remove = new AOButton(this, ao_app);
ui_iniswap_dropdown = new QComboBox(this);
ui_iniswap_dropdown->setContextMenuPolicy(Qt::CustomContextMenu);
+ ui_iniswap_dropdown->view()->setTextElideMode(Qt::ElideLeft);
ui_iniswap_remove = new AOButton(this, ao_app);
ui_sfx_dropdown = new QComboBox(this);
ui_sfx_dropdown->setContextMenuPolicy(Qt::CustomContextMenu);
+ ui_sfx_dropdown->view()->setTextElideMode(Qt::ElideLeft);
ui_sfx_remove = new AOButton(this, ao_app);
ui_effects_dropdown = new QComboBox(this);
+ ui_effects_dropdown->view()->setTextElideMode(Qt::ElideLeft);
ui_effects_dropdown->setContextMenuPolicy(Qt::CustomContextMenu);
ui_defense_bar = new AOImage(this, ao_app);
@@ -1638,6 +1644,11 @@ void Courtroom::append_server_chatmessage(QString p_name, QString p_message,
ui_server_chatlog->append_chatmessage(p_name, p_message, color);
+
+ if (ao_app->get_auto_logging_enabled() && !ao_app->log_filename.isEmpty()) {
+ QString full = "[OOC][" + QDateTime::currentDateTime().toUTC().toString() + "] " + p_name + ": " + p_message;
+ ao_app->append_to_file(full, ao_app->log_filename, true);
+ }
}
void Courtroom::on_authentication_state_received(int p_state)
@@ -1660,7 +1671,7 @@ void Courtroom::on_chat_return_pressed()
if (is_muted)
return;
- if ((anim_state < 3 || text_state < 2) && objection_state == 0)
+ if (text_state < 2 && objection_state == 0)
return;
ui_ic_chat_message->blockSignals(true);
@@ -1987,15 +1998,6 @@ void Courtroom::chatmessage_enqueue(QStringList p_contents)
void Courtroom::chatmessage_dequeue()
{
- // Chat stopped being processed, indicate that the user can post their message now.
- QString f_custom_theme;
- if (ao_app->is_customchat_enabled()) {
- QString f_char = m_chatmessage[CHAR_NAME];
- f_custom_theme = ao_app->get_chat(f_char);
- }
- ui_vp_chat_arrow->transform_mode = ao_app->get_misc_scaling(f_custom_theme);
- ui_vp_chat_arrow->load_image("chat_arrow", f_custom_theme);
-
// Nothing to parse in the queue
if (chatmessage_queue.isEmpty())
return;
@@ -2188,8 +2190,6 @@ bool Courtroom::handle_objection()
objection_mod = m_chatmessage[OBJECTION_MOD].toInt();
}
-
-
// if an objection is used
if (objection_mod <= 4 && objection_mod >= 1) {
ui_vp_objection->set_static_duration(shout_static_time);
@@ -2233,8 +2233,10 @@ bool Courtroom::handle_objection()
filename, m_chatmessage[CHAR_NAME],
ao_app->get_chat(m_chatmessage[CHAR_NAME]));
sfx_player->clear(); // Objection played! Cut all sfx.
+ ui_vp_player_char->set_play_once(true);
return true;
}
+ if (m_chatmessage[EMOTE] != "")
display_character();
return false;
}
@@ -2393,22 +2395,31 @@ void Courtroom::handle_ic_message()
// Update the chatbox information
initialize_chatbox();
- // Display our own character
- display_character();
+ int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
+ bool immediate = m_chatmessage[IMMEDIATE].toInt() == 1;
+ if (m_chatmessage[EMOTE] != "") {
+ // Display our own character
+ display_character();
- // Reset the pair character
- ui_vp_sideplayer_char->stop();
- ui_vp_sideplayer_char->move(0, 0);
+ // Reset the pair character
+ ui_vp_sideplayer_char->stop();
+ ui_vp_sideplayer_char->move(0, 0);
- // If the emote_mod is not zooming
- int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
- if (emote_mod != 5 && emote_mod != 6) {
- // Display the pair character
- display_pair_character(m_chatmessage[OTHER_CHARID], m_chatmessage[OTHER_OFFSET]);
- }
+ // If the emote_mod is not zooming
+ if (emote_mod != 5 && emote_mod != 6) {
+ // Display the pair character
+ display_pair_character(m_chatmessage[OTHER_CHARID], m_chatmessage[OTHER_OFFSET]);
+ }
- // Parse the emote_mod part of the chat message
- handle_emote_mod(m_chatmessage[EMOTE_MOD].toInt(), m_chatmessage[IMMEDIATE].toInt() == 1);
+ // Parse the emote_mod part of the chat message
+ handle_emote_mod(emote_mod, immediate);
+ }
+ else
+ {
+ start_chat_ticking();
+ if (emote_mod == 1 || emote_mod == 2 || emote_mod == 6 || immediate)
+ play_sfx();
+ }
// if we have instant objections disabled, and queue is not empty, check if next message after this is an objection.
if (!ao_app->is_instant_objection_enabled() && chatmessage_queue.size() > 0)
@@ -2525,7 +2536,6 @@ void Courtroom::initialize_chatbox()
if (f_charid >= 0 && f_charid < char_list.size() &&
(m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())) {
QString real_name = char_list.at(f_charid).name;
- ui_vp_player_char->set_static_duration(0);
QString f_showname = ao_app->get_showname(real_name);
ui_vp_showname->setText(f_showname);
@@ -2554,19 +2564,6 @@ void Courtroom::initialize_chatbox()
if (!ui_vp_chatbox->set_image("chat", p_misc))
ui_vp_chatbox->set_image("chatbox", p_misc);
- // This should probably be called only if any change from the last chat
- // arrow was actually detected.
- pos_size_type design_ini_result = ao_app->get_element_dimensions(
- "chat_arrow", "courtroom_design.ini", p_misc);
- if (design_ini_result.width < 0 || design_ini_result.height < 0) {
- qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini";
- ui_vp_chat_arrow->hide();
- }
- else {
- ui_vp_chat_arrow->move(design_ini_result.x + ui_vp_chatbox->x(), design_ini_result.y + ui_vp_chatbox->y());
- ui_vp_chat_arrow->combo_resize(design_ini_result.width,
- design_ini_result.height);
- }
// Remember to set the showname font before the font metrics check.
set_font(ui_vp_showname, "", "showname", customchar);
@@ -2622,6 +2619,20 @@ void Courtroom::initialize_chatbox()
}
}
+ // This should probably be called only if any change from the last chat
+ // arrow was actually detected.
+ pos_size_type design_ini_result = ao_app->get_element_dimensions(
+ "chat_arrow", "courtroom_design.ini", p_misc);
+ if (design_ini_result.width < 0 || design_ini_result.height < 0) {
+ qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini";
+ ui_vp_chat_arrow->hide();
+ }
+ else {
+ ui_vp_chat_arrow->move(design_ini_result.x + ui_vp_chatbox->x(), design_ini_result.y + ui_vp_chatbox->y());
+ ui_vp_chat_arrow->combo_resize(design_ini_result.width,
+ design_ini_result.height);
+ }
+
QString font_name;
QString chatfont = ao_app->get_chat_font(m_chatmessage[CHAR_NAME]);
if (chatfont != "")
@@ -2672,8 +2683,6 @@ void Courtroom::display_evidence_image()
void Courtroom::handle_ic_speaking()
{
- // Display the evidence
- display_evidence_image();
QString side = m_chatmessage[SIDE];
int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
// emote_mod 5 is zoom and emote_mod 6 is zoom w/ preanim.
@@ -3183,6 +3192,9 @@ void Courtroom::play_preanim(bool immediate)
void Courtroom::preanim_done()
{
+ // Currently, someone's talking over us mid-preanim...
+ if (anim_state != 1 && anim_state != 4)
+ return;
anim_state = 1;
switch(m_chatmessage[DESK_MOD].toInt()) {
case 4:
@@ -3212,6 +3224,9 @@ void Courtroom::start_chat_ticking()
if (text_state != 0)
return;
+ // Display the evidence
+ display_evidence_image();
+
if (m_chatmessage[EFFECTS] != "") {
QStringList fx_list = m_chatmessage[EFFECTS].split("|");
QString fx = fx_list[0];
@@ -3243,6 +3258,10 @@ void Courtroom::start_chat_ticking()
ui_vp_chatbox->show();
ui_vp_message->show();
}
+ else {
+ ui_vp_chatbox->hide();
+ ui_vp_message->hide();
+ }
// If we're not already waiting on the next message, start the timer. We could be overriden if there's an objection planned.
int delay = ao_app->stay_time();
if (delay > 0 && !text_queue_timer->isActive())
@@ -3300,26 +3319,31 @@ void Courtroom::chat_tick()
if (tick_pos >= f_message.size()) {
text_state = 2;
- if (anim_state < 3) {
- QStringList c_paths = {
- ao_app->get_image_suffix(ao_app->get_character_path(m_chatmessage[CHAR_NAME], "(c)" + m_chatmessage[EMOTE])),
- ao_app->get_image_suffix(ao_app->get_character_path(m_chatmessage[CHAR_NAME], "(c)/" + m_chatmessage[EMOTE]))
- };
- // if there is a (c) animation for this emote and we haven't played it already
- if (file_exists(ui_vp_player_char->find_image(c_paths)) &&(!c_played)) {
- anim_state = 5;
- ui_vp_player_char->set_play_once(true);
- filename = "(c)" + m_chatmessage[EMOTE];
- c_played = true;
- }
- else {
- anim_state = 3;
- ui_vp_player_char->set_play_once(false);
- filename = "(a)" + m_chatmessage[EMOTE];
+ // Check if we're a narrator msg
+ if (m_chatmessage[EMOTE] != "") {
+ if (anim_state < 3) {
+ QStringList c_paths = {
+ ao_app->get_image_suffix(ao_app->get_character_path(m_chatmessage[CHAR_NAME], "(c)" + m_chatmessage[EMOTE])),
+ ao_app->get_image_suffix(ao_app->get_character_path(m_chatmessage[CHAR_NAME], "(c)/" + m_chatmessage[EMOTE]))
+ };
+ // if there is a (c) animation for this emote and we haven't played it already
+ if (file_exists(ui_vp_player_char->find_image(c_paths)) &&(!c_played)) {
+ anim_state = 5;
+ ui_vp_player_char->set_play_once(true);
+ filename = "(c)" + m_chatmessage[EMOTE];
+ c_played = true;
+ }
+ else {
+ anim_state = 3;
+ ui_vp_player_char->set_play_once(false);
+ filename = "(a)" + m_chatmessage[EMOTE];
+ }
+ ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0,
+ false);
}
- ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0,
- false);
}
+ else // We're a narrator msg
+ anim_state = 3;
QString f_char;
QString f_custom_theme;
if (ao_app->is_customchat_enabled()) {
@@ -3362,21 +3386,8 @@ void Courtroom::chat_tick()
// Alignment characters
if (tick_pos < 2) {
- if (f_rest.startsWith("~~")) {
- tick_pos = f_rest.indexOf("~~");
- f_rest.remove(tick_pos, 2);
- tick_pos += 2;
- }
- else if (f_rest.startsWith("~>")) {
- tick_pos = f_rest.indexOf("~>");
- f_rest.remove(tick_pos, 2);
- tick_pos += 2;
- }
- else if (f_rest.startsWith("<>")) {
- tick_pos = f_rest.indexOf("<>");
- f_rest.remove(tick_pos, 2);
+ if (f_rest.startsWith("~~") || f_rest.startsWith("~>") || f_rest.startsWith("<>"))
tick_pos += 2;
- }
}
f_rest.remove(0, tick_pos);
QTextBoundaryFinder tbf(QTextBoundaryFinder::Grapheme, f_rest);
@@ -3520,28 +3531,30 @@ void Courtroom::chat_tick()
msg_delay = qMin(max_delay, msg_delay * punctuation_modifier);
}
- // If this color is talking
- if (color_is_talking && anim_state != 2 &&
- anim_state <
- 4) // Set it to talking as we're not on that already (though we have
- // to avoid interrupting a non-interrupted preanim)
- {
- ui_vp_player_char->stop();
- ui_vp_player_char->set_play_once(false);
- filename = "(b)" + m_chatmessage[EMOTE];
- ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0,
- false);
- anim_state = 2;
- }
- else if (!color_is_talking && anim_state < 3 &&
- anim_state != 3) // Set it to idle as we're not on that already
- {
- ui_vp_player_char->stop();
- ui_vp_player_char->set_play_once(false);
- filename = "(a)" + m_chatmessage[EMOTE];
- ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0,
- false);
- anim_state = 3;
+ if (m_chatmessage[EMOTE] != "") {
+ // If this color is talking
+ if (color_is_talking && anim_state != 2 &&
+ anim_state <
+ 4) // Set it to talking as we're not on that already (though we have
+ // to avoid interrupting a non-interrupted preanim)
+ {
+ ui_vp_player_char->stop();
+ ui_vp_player_char->set_play_once(false);
+ filename = "(b)" + m_chatmessage[EMOTE];
+ ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0,
+ false);
+ anim_state = 2;
+ }
+ else if (!color_is_talking && anim_state < 3 &&
+ anim_state != 3) // Set it to idle as we're not on that already
+ {
+ ui_vp_player_char->stop();
+ ui_vp_player_char->set_play_once(false);
+ filename = "(a)" + m_chatmessage[EMOTE];
+ ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0,
+ false);
+ anim_state = 3;
+ }
}
// Continue ticking
chat_tick_timer->start(msg_delay);
@@ -3892,14 +3905,8 @@ void Courtroom::case_called(QString msg, bool def, bool pro, bool jud, bool jur,
{
if (ui_casing->isChecked()) {
ui_server_chatlog->append(msg);
- if ((ao_app->get_casing_defence_enabled() && def) ||
- (ao_app->get_casing_prosecution_enabled() && pro) ||
- (ao_app->get_casing_judge_enabled() && jud) ||
- (ao_app->get_casing_juror_enabled() && jur) ||
- (ao_app->get_casing_steno_enabled() && steno)) {
- modcall_player->play(ao_app->get_court_sfx("case_call"));
- ao_app->alert(this);
- }
+ modcall_player->play(ao_app->get_court_sfx("case_call"));
+ ao_app->alert(this);
}
}
@@ -4799,7 +4806,7 @@ void Courtroom::music_random()
QTreeWidgetItemIterator::NotHidden |
QTreeWidgetItemIterator::NoChildren);
while (*it) {
- if ((*it)->parent()->isExpanded()) {
+ if (!(*it)->parent() || (*it)->parent()->isExpanded()) { // add top level songs and songs in expanded categories
clist += (*it);
}
++it;
@@ -5259,9 +5266,8 @@ void Courtroom::on_reload_theme_clicked()
set_widgets();
update_character(m_cid);
enter_courtroom();
+ gen_char_rgb_list(ao_app->get_chat(current_char));
- anim_state = 4;
- text_state = 3;
objection_custom = "";
// to update status on the background
diff --git a/src/demoserver.cpp b/src/demoserver.cpp
index 88dfdb4..764cf22 100644
--- a/src/demoserver.cpp
+++ b/src/demoserver.cpp
@@ -150,7 +150,8 @@ void DemoServer::handle_packet(AOPacket packet)
}
else if (header == "CC") {
client_sock->write("PV#0#CID#-1#%");
- client_sock->write("CT#DEMO#Demo file loaded. Send /play or > in OOC to begin playback.#1#%");
+ QString packet = "CT#DEMO#" + tr("Demo file loaded. Send /play or > in OOC to begin playback.") + "#1#%";
+ client_sock->write(packet.toUtf8());
}
else if (header == "CT") {
if (contents[1].startsWith("/load"))
@@ -159,14 +160,16 @@ void DemoServer::handle_packet(AOPacket packet)
if (path.isEmpty())
return;
load_demo(path);
- client_sock->write("CT#DEMO#Demo file loaded. Send /play or > in OOC to begin playback.#1#%");
+ QString packet = "CT#DEMO#" + tr("Demo file loaded. Send /play or > in OOC to begin playback.") + "#1#%";
+ client_sock->write(packet.toUtf8());
}
else if (contents[1].startsWith("/play") || contents[1] == ">")
{
if (timer->interval() != 0 && !timer->isActive())
{
timer->start();
- client_sock->write("CT#DEMO#Resuming playback.#1#%");
+ QString packet = "CT#DEMO#" + tr("Resuming playback.") + "#1#%";
+ client_sock->write(packet.toUtf8());
}
else
{
@@ -180,7 +183,8 @@ void DemoServer::handle_packet(AOPacket packet)
int timeleft = timer->remainingTime();
timer->stop();
timer->setInterval(timeleft);
- client_sock->write("CT#DEMO#Pausing playback.#1#%");
+ QString packet = "CT#DEMO#" + tr("Pausing playback.") + "#1#%";
+ client_sock->write(packet.toUtf8());
}
else if (contents[1].startsWith("/max_wait"))
{
@@ -194,29 +198,37 @@ void DemoServer::handle_packet(AOPacket packet)
if (p_max_wait < 0)
p_max_wait = -1;
max_wait = p_max_wait;
- client_sock->write("CT#DEMO#Setting max_wait to ");
+ QString packet = "CT#DEMO#" + tr("Setting max_wait to") + " ";
+ client_sock->write(packet.toUtf8());
client_sock->write(QString::number(max_wait).toUtf8());
- client_sock->write(" milliseconds.#1#%");
+ packet = " " + tr("milliseconds.") + "#1#%";
+ client_sock->write(packet.toUtf8());
}
else
{
- client_sock->write("CT#DEMO#Not a valid integer!#1#%");
+ QString packet = "CT#DEMO#" + tr("Not a valid integer!") + "#1#%";
+ client_sock->write(packet.toUtf8());
}
}
else
{
- client_sock->write("CT#DEMO#Current max_wait is ");
- client_sock->write(QString::number(max_wait).toUtf8());
- client_sock->write(" milliseconds.#1#%");
+
+ QString packet = "CT#DEMO#" + tr("Current max_wait is") + " ";
+ client_sock->write(packet.toUtf8());
+ client_sock->write(QString::number(max_wait).toUtf8());
+ packet = " " + tr("milliseconds.") + "#1#%";
+ client_sock->write(packet.toUtf8());
}
}
else if (contents[1].startsWith("/min_wait"))
{
- client_sock->write("CT#DEMO#min_wait is deprecated. Use the client Settings for minimum wait instead!");
+ QString packet = "CT#DEMO#" + tr("min_wait is deprecated. Use the client Settings for minimum wait instead!") + "#1#%";
+ client_sock->write(packet.toUtf8());
}
else if (contents[1].startsWith("/help"))
{
- client_sock->write("CT#DEMO#Available commands:\nload, play, pause, max_wait, help#1#%");
+ QString packet = "CT#DEMO#" + tr("Available commands:\nload, play, pause, max_wait, help") + "#1#%";
+ client_sock->write(packet.toUtf8());
}
}
}
@@ -233,8 +245,9 @@ void DemoServer::load_demo(QString filename)
demo_stream.setCodec("UTF-8");
QString line = demo_stream.readLine();
while (!line.isNull()) {
- if (!line.endsWith("%")) {
+ while (!line.endsWith("%")) {
line += "\n";
+ line += demo_stream.readLine();
}
demo_data.enqueue(line);
line = demo_stream.readLine();
@@ -264,12 +277,16 @@ void DemoServer::playback()
// Skip the difference on the timers
emit skip_timers(wait_packet.get_contents().at(0).toInt() - duration);
}
+ else if (timer->interval() != 0 && duration + elapsed_time > timer->interval()) {
+ duration = qMax(0, timer->interval() - elapsed_time);
+ emit skip_timers(wait_packet.get_contents().at(0).toInt() - duration);
+ }
elapsed_time += duration;
timer->start(duration);
}
- else
- {
- client_sock->write("CT#DEMO#Reached the end of the demo file. Send /play or > in OOC to restart, or /load to open a new file.#1#%");
+ else {
+ QString end_packet = "CT#DEMO#" + tr("Reached the end of the demo file. Send /play or > in OOC to restart, or /load to open a new file.") + "#1#%";
+ client_sock->write(end_packet.toUtf8());
timer->setInterval(0);
}
}
diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp
index f3810ca..dc76ec1 100644
--- a/src/packet_distribution.cpp
+++ b/src/packet_distribution.cpp
@@ -121,6 +121,7 @@ void AOApplication::append_to_demofile(QString packet_string)
void AOApplication::server_packet_received(AOPacket *p_packet)
{
QStringList f_contents_encoded = p_packet->get_contents();
+ QString f_packet_encoded = p_packet->to_string();
p_packet->net_decode();
QString header = p_packet->get_header();
@@ -182,7 +183,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
w_courtroom->append_server_chatmessage(f_contents.at(0),
f_contents.at(1), "0");
- append_to_demofile(p_packet->to_string(true));
+ append_to_demofile(f_packet_encoded);
}
}
else if (header == "FL") {
@@ -307,7 +308,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
this->log_filename = QDateTime::currentDateTime().toUTC().toString(
"'logs/" + server_name.remove(QRegExp("[\\\\/:*?\"<>|\']")) +
"/'yyyy-MM-dd hh-mm-ss t'.log'");
- this->write_to_file("Joined server " + server_name + " on address " +
+ this->write_to_file("Joined server " + server_name + " hosted on address " +
server_address + " on " +
QDateTime::currentDateTime().toUTC().toString(),
log_filename, true);
@@ -368,7 +369,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
}
send_server_packet(new AOPacket("RM#%"));
- append_to_demofile(p_packet->to_string(true));
+ append_to_demofile(f_packet_encoded);
}
else if (header == "SM") {
if (!courtroom_constructed || courtroom_loaded)
@@ -471,7 +472,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
2) // We have a pos included in the background packet!
w_courtroom->set_side(f_contents.at(1));
w_courtroom->set_background(f_contents.at(0), f_contents.size() >= 2);
- append_to_demofile(p_packet->to_string(true));
+ append_to_demofile(f_packet_encoded);
}
}
else if (header == "SP") {
@@ -481,7 +482,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (courtroom_constructed) // We were sent a "set position" packet
{
w_courtroom->set_side(f_contents.at(0));
- append_to_demofile(p_packet->to_string(true));
+ append_to_demofile(f_packet_encoded);
}
}
else if (header == "SD") // Send pos dropdown
@@ -507,14 +508,14 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (courtroom_constructed && courtroom_loaded)
{
w_courtroom->chatmessage_enqueue(p_packet->get_contents());
- append_to_demofile(p_packet->to_string(true));
+ append_to_demofile(f_packet_encoded);
}
}
else if (header == "MC") {
if (courtroom_constructed && courtroom_loaded)
{
w_courtroom->handle_song(&p_packet->get_contents());
- append_to_demofile(p_packet->to_string(true));
+ append_to_demofile(f_packet_encoded);
}
}
else if (header == "RT") {
@@ -525,7 +526,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
w_courtroom->handle_wtce(f_contents.at(0), 0);
else if (f_contents.size() == 2) {
w_courtroom->handle_wtce(f_contents.at(0), f_contents.at(1).toInt());
- append_to_demofile(p_packet->to_string(true));
+ append_to_demofile(f_packet_encoded);
}
}
}
@@ -534,7 +535,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
{
w_courtroom->set_hp_bar(f_contents.at(0).toInt(),
f_contents.at(1).toInt());
- append_to_demofile(p_packet->to_string(true));
+ append_to_demofile(f_packet_encoded);
}
}
else if (header == "LE") {
@@ -560,7 +561,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
}
w_courtroom->set_evidence_list(f_evi_list);
- append_to_demofile(p_packet->to_string(true));
+ append_to_demofile(f_packet_encoded);
}
}
else if (header == "ARUP") {
@@ -615,7 +616,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
w_courtroom->mod_called(f_contents.at(0));
}
else if (header == "CASEA") {
- if (courtroom_constructed && f_contents.size() > 6)
+ if (courtroom_constructed && f_contents.size() >= 6)
w_courtroom->case_called(f_contents.at(0), f_contents.at(1) == "1",
f_contents.at(2) == "1", f_contents.at(3) == "1",
f_contents.at(4) == "1",
@@ -665,7 +666,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
w_courtroom->set_clock_visibility(id, true);
else if (type == 3)
w_courtroom->set_clock_visibility(id, false);
- append_to_demofile(p_packet->to_string(true));
+ append_to_demofile(f_packet_encoded);
}
else if (header == "CHECK") {
if (!courtroom_constructed)
diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp
index f6a5d6c..a671d61 100644
--- a/src/text_file_functions.cpp
+++ b/src/text_file_functions.cpp
@@ -243,33 +243,31 @@ QVector<server_type> AOApplication::read_serverlist_txt()
serverlist_txt.setFileName(serverlist_txt_path);
- if (!serverlist_txt.open(QIODevice::ReadOnly)) {
- return f_server_list;
- }
+ if (serverlist_txt.open(QIODevice::ReadOnly)) {
+ QTextStream in(&serverlist_txt);
- QTextStream in(&serverlist_txt);
+ while (!in.atEnd()) {
+ QString line = in.readLine();
+ server_type f_server;
+ QStringList line_contents = line.split(":");
- while (!in.atEnd()) {
- QString line = in.readLine();
- server_type f_server;
- QStringList line_contents = line.split(":");
-
- if (line_contents.size() < 3)
- continue;
+ if (line_contents.size() < 3)
+ continue;
- f_server.ip = line_contents.at(0);
- f_server.port = line_contents.at(1).toInt();
- f_server.name = line_contents.at(2);
- f_server.desc = "";
+ f_server.ip = line_contents.at(0);
+ f_server.port = line_contents.at(1).toInt();
+ f_server.name = line_contents.at(2);
+ f_server.desc = "";
- f_server_list.append(f_server);
+ f_server_list.append(f_server);
+ }
}
server_type demo_server;
demo_server.ip = "127.0.0.1";
demo_server.port = 99999;
- demo_server.name = "Demo playback";
- demo_server.desc = "Play back demos you have previously recorded";
+ demo_server.name = tr("Demo playback");
+ demo_server.desc = tr("Play back demos you have previously recorded");
f_server_list.append(demo_server);
return f_server_list;