view StorylineTextTable.cpp @ 253:f1218b9d67f1

merge
author Gloval
date Mon, 18 Feb 2013 09:03:15 +0400
parents 2799737f8a74
children 7f19b3f7d935
line wrap: on
line source

#include <stdlib.h>
#include <string.h>

#include "LOD.h"
#include "allocator.h"
#include "texts.h"
#include "StorylineTextTable.h"

char *pHistoryTXT_Raw;
struct StorylineText *pStorylineText;  

//----- (00453E6D) --------------------------------------------------------
void StorylineText::Initialize()
	{

	int i;
	char* test_string;
	unsigned char c;
	bool break_loop;
	unsigned int temp_str_len;
	char* tmp_pos;
	int decode_step;

	if ( pHistoryTXT_Raw )
		pAllocator->FreeChunk(pHistoryTXT_Raw);
	pHistoryTXT_Raw = NULL;
	pHistoryTXT_Raw = (char *)pEvents_LOD->LoadRaw("history.txt", 0);
	strtok(pHistoryTXT_Raw, "\r");

	for (i=0;i<29;++i)
		{
		test_string = strtok(NULL, "\r") + 1;
		break_loop = false;
		decode_step=0;
		do 
			{
			c = *(unsigned char*)test_string;
			temp_str_len = 0;
			while((c!='\t')&&(c>0))
				{
				++temp_str_len;
				c=test_string[temp_str_len];
				}		
			tmp_pos=test_string+temp_str_len;
			if (*tmp_pos == 0)
				break_loop = true;
			*tmp_pos = 0;
			if (temp_str_len)
				{
				switch (decode_step)
					{
				case 1: 
					StoreLine[i+1].pText=RemoveQuotes(test_string);
					break;
				case 2:
					StoreLine[i+1].uTime=atoi(test_string);  //strange but in text here string not digit
					break;
				case 3:
					StoreLine[i+1].pPageTitle=RemoveQuotes(test_string);
					break;
					}
				}
			else
				{ 
				break_loop = true;
				}
			++decode_step;
			test_string=tmp_pos+1;
			} while ((decode_step<4)&&!break_loop);
		}
	}