aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Skoland <davidskoland@gmail.com>2017-01-26 00:23:53 +0100
committerDavid Skoland <davidskoland@gmail.com>2017-01-26 00:23:53 +0100
commitb4b533b72492da38381ad2fbb6c5aad99e30f110 (patch)
treee7a017a7ea8876b8006c17c88e9ef846e0129775
parent99aa327318ab00f2049cfcefadd353c3a4e06bf7 (diff)
finished legacy loading process
-rw-r--r--aoapplication.cpp3
-rw-r--r--courtroom.cpp16
-rw-r--r--courtroom.h1
-rw-r--r--datatypes.h2
-rw-r--r--packet_distribution.cpp94
5 files changed, 107 insertions, 9 deletions
diff --git a/aoapplication.cpp b/aoapplication.cpp
index bf734343..5388fc01 100644
--- a/aoapplication.cpp
+++ b/aoapplication.cpp
@@ -54,9 +54,6 @@ void AOApplication::construct_courtroom()
w_courtroom = new Courtroom(this);
courtroom_constructed = true;
-
- //D3BUG
- w_courtroom->show();
}
void AOApplication::destruct_courtroom()
diff --git a/courtroom.cpp b/courtroom.cpp
index 231d6e9c..282c70cd 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -296,6 +296,22 @@ void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier)
p_widget->resize(design_ini_result.width, design_ini_result.height);
}
+void Courtroom::set_taken(int n_char, bool p_taken)
+{
+ if (n_char >= char_list.size())
+ {
+ qDebug() << "W: set_taken attempted to set an index bigger than char_list size";
+ return;
+ }
+
+ char_type f_char;
+ f_char.name = char_list.at(0).name;
+ f_char.description = char_list.at(1).description;
+ f_char.taken = p_taken;
+
+ char_list.replace(n_char, f_char);
+}
+
void Courtroom::on_change_character_clicked()
{
ui_char_select_background->show();
diff --git a/courtroom.h b/courtroom.h
index 1278c835..ec31961f 100644
--- a/courtroom.h
+++ b/courtroom.h
@@ -31,6 +31,7 @@ public:
void set_widgets();
void set_size_and_pos(QWidget *p_widget, QString p_identifier);
+ void set_taken(int n_char, bool p_taken);
~Courtroom();
diff --git a/datatypes.h b/datatypes.h
index 0d396bfa..9fe50166 100644
--- a/datatypes.h
+++ b/datatypes.h
@@ -26,12 +26,14 @@ struct char_type
{
QString name;
QString description;
+ bool taken;
};
struct evi_type
{
QString name;
QString description;
+ QString image;
};
struct chatmessage_type
diff --git a/packet_distribution.cpp b/packet_distribution.cpp
index 84ace315..a20429e0 100644
--- a/packet_distribution.cpp
+++ b/packet_distribution.cpp
@@ -157,6 +157,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (f_contents.at(n_element).toInt() != loaded_chars)
break;
+ //this means we are on the last element and checking n + 1 element will be game over so
if (n_element == f_contents.size() - 1)
break;
@@ -167,6 +168,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
char_type f_char;
f_char.name = sub_elements.at(0);
f_char.description = sub_elements.at(1);
+ //temporary. the CharsCheck packet sets this properly
+ f_char.taken = false;
++loaded_chars;
@@ -177,28 +180,107 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (loaded_chars < char_list_size)
{
- qDebug() << "loaded_chars" << loaded_chars;
QString next_packet_number = QString::number(((loaded_chars - 1) / 10) + 1);
- AOPacket *f_packet = new AOPacket("AN#" + next_packet_number + "#%");
- send_server_packet(f_packet);
+ send_server_packet(new AOPacket("AN#" + next_packet_number + "#%"));
}
- else if (loaded_chars >= char_list_size)
+ else
{
if (evidence_list_size == 0)
send_server_packet(new AOPacket("AM#0#%"));
else
send_server_packet(new AOPacket("AE#0#%"));
}
+ }
+ else if (header == "EI"){
+ if (!courtroom_constructed)
+ return;
+
+ // +1 because evidence starts at 1 rather than 0 for whatever reason
+ //enjoy fanta
+ if (f_contents.at(0).toInt() != loaded_evidence + 1)
+ return;
+
+ if (f_contents.size() < 2)
+ return;
+
+ QStringList sub_elements = f_contents.at(1).split("&");
+ if (sub_elements.size() < 4)
+ return;
+ evi_type f_evi;
+ f_evi.name = sub_elements.at(0);
+ f_evi.description = sub_elements.at(1);
+ //no idea what the number at position 2 is. probably an identifier?
+ f_evi.image = sub_elements.at(3);
+ ++loaded_evidence;
+
+ w_lobby->set_loading_text("Loading evidence:\n" + QString::number(loaded_evidence) + "/" + QString::number(evidence_list_size));
+
+ w_courtroom->append_evidence(f_evi);
+
+ if (loaded_evidence < evidence_list_size)
+ {
+ qDebug() << "loaded evidence: " << loaded_evidence;
+ QString next_packet_number = QString::number(loaded_evidence);
+ send_server_packet(new AOPacket("AE#" + next_packet_number + "#%"));
+ }
+ else
+ {
+ send_server_packet(new AOPacket("AM#0#%"));
+ }
}
- else if (header == "EI"){
+ else if (header == "EM")
+ {
+ if (!courtroom_constructed)
+ return;
+
+ for (int n_element = 0 ; n_element < f_contents.size() ; n_element += 2)
+ {
+ if (f_contents.at(n_element).toInt() != loaded_music)
+ break;
+
+ if (n_element == f_contents.size() - 1)
+ break;
+
+ QString f_music = f_contents.at(n_element + 1);
+
+ ++loaded_music;
+
+ w_lobby->set_loading_text("Loading music:\n" + QString::number(loaded_music) + "/" + QString::number(music_list_size));
+ w_courtroom->append_music(f_music);
+ }
+
+ //apparently we need to intentionally send another AM packet to get onwards in the loading process
+ //in spite of the fact that we actually received all the music
+ //enjoy fanta
+ //if (loaded_music < music_list_size)
+ //{
+ QString next_packet_number = QString::number(((loaded_music - 1) / 10) + 1);
+ send_server_packet(new AOPacket("AM#" + next_packet_number + "#%"));
+ //}
}
- else if (header == "EM"){
+ if (header == "CharsCheck")
+ {
+ for (int n_char = 0 ; n_char < f_contents.size() ; ++n_char)
+ {
+ if (f_contents.at(n_char) == "-1")
+ w_courtroom->set_taken(n_char, true);
+ else
+ w_courtroom->set_taken(n_char, false);
+ }
+ }
+ if (header == "DONE")
+ {
+ if (!courtroom_constructed)
+ return;
+
+ w_courtroom->show();
+ destruct_lobby();
}
}