view StorylineTextTable.cpp @ 246:1bfe546561c4

sprintfex
author Nomad
date Mon, 18 Feb 2013 03:58:08 +0200
parents 0df4136b6aac
children 2799737f8a74
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()
{
  char *v1; // ebx@1
  StorylineText *v2; // esi@1
  char *v3; // ecx@4
  char v4; // dl@5
  char *v5; // eax@5
  int v6; // esi@9
  int v7; // [sp+Ch] [bp-10h]@3
  int v8; // [sp+10h] [bp-Ch]@4
  char *v9; // [sp+14h] [bp-8h]@4
  int Str; // [sp+18h] [bp-4h]@3
  int i,j;
	char* test_string;
	unsigned char c;
	bool break_loop;
	unsigned int temp_str_len;
	char* tmp_pos;
	int decode_step;
  v1 = 0;
  v2 = this;
  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);
		}
}