Skip to content

Commit

Permalink
Tasofro: tweak a few things to support HM story mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
brliron committed Aug 31, 2017
1 parent 33c56d9 commit ddc45e9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
34 changes: 19 additions & 15 deletions thcrap_tasofro/src/pl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

#include <thcrap.h>
#include "thcrap_tasofro.h"
#include "pl.h"

void TasofroPl::readField(const char *in, size_t& pos, size_t size, std::string& out)
Expand Down Expand Up @@ -54,7 +55,7 @@ TasofroPl::ALine* TasofroPl::readLine(const char*& file, size_t& size)

if (size > 0 && *file == '#') {
pos = 0;
while (file[pos] != '\n') {
while (pos < size && file[pos] != '\n') {
pos++;
}
if (pos > 0 && file[pos - 1] == '\r') {
Expand Down Expand Up @@ -384,20 +385,18 @@ bool TasofroPl::Text::parseCommand(json_t *patch, int json_line_num)
}
this->nb_lines = i - json_line_num;

// If this is the staffroll line, try to see if we are in the last balloon.
this->is_staffroll_last_balloon = false;
if (this->is_staffroll) {
unsigned int j;
for (j = i + 1; j < json_array_size(patch); j++) {
line = json_array_get_string(patch, j);
if (strncmp(line, "<balloon", 8) != 0) {
break;
}
}
if (j >= json_array_size(patch)) {
this->is_staffroll_last_balloon = true;
// Try to see if we are in the last balloon.
this->is_last_balloon = false;
unsigned int j;
for (j = i + 1; j < json_array_size(patch); j++) {
line = json_array_get_string(patch, j);
if (strncmp(line, "<balloon", 8) != 0) {
break;
}
}
if (j >= json_array_size(patch)) {
this->is_last_balloon = true;
}

// If the balloon is too small for our text to fit, expand it automatically.
if (this->nb_lines > 1 && balloon_size == "05x2") {
Expand Down Expand Up @@ -441,7 +440,7 @@ void TasofroPl::Text::beginLine(std::list<ALine*> file, std::list<ALine*>::itera
this->ignore_clear_balloon = false;


if (this->is_staffroll_last_balloon) {
if (game_id >= TH145 && this->is_last_balloon) {
this->last_char = "";
}
else if (this->is_staffroll) {
Expand All @@ -453,7 +452,12 @@ void TasofroPl::Text::patchLine(const char *text, std::list<ALine*> file, std::l
{
std::string formattedText = text;
if (this->cur_line == this->nb_lines) {
formattedText += this->last_char;
if (this->last_char.empty() == false) {
formattedText += this->last_char;
}
else if (this->is_last_balloon == false) {
formattedText += "\\";
}
}

if (this->syntax == STORY) {
Expand Down
2 changes: 1 addition & 1 deletion thcrap_tasofro/src/pl.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace TasofroPl
std::string last_char;
Syntax syntax;
bool is_staffroll;
bool is_staffroll_last_balloon;
bool is_last_balloon;

int cur_line;
int nb_lines;
Expand Down
1 change: 1 addition & 0 deletions thcrap_tasofro/src/thcrap_tasofro.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ typedef enum {
// • filename hash: uses hash = (hash ^ ch) * 0x1000193
// • XOR: uses an additional AUX parameter
// • XOR: key compunents are multiplied by -1
// • endings: the last line in the text may be on another line in the pl file, and it doesn't wait for an input.
// • spells: using data/csv/spellcards/*.csv and data/system/char_select3/*/equip/*/000.png.csv
TH145,

Expand Down

0 comments on commit ddc45e9

Please sign in to comment.