コード例 #1
0
ファイル: CStrStb.hpp プロジェクト: TheDgtl/osrose
    bool LoadSTB(char* path)
    {
        CleanUp();

        CRoseFile* fh = new CRoseFile(path, FM_READ | FM_BINARY);
        if(!fh->IsOpen()) {
            delete fh;
            return false;
        } // if is open

        fh->Seek(4, SEEK_CUR);
        dword offset = fh->Get<dword>();

        _Rows = fh->Get<dword>();
        _Columns = fh->Get<dword>();

        _Rows--;
        _Columns--;

        fh->SetAbsPos(offset);
        _Data = new char**[_Rows];
        for(dword i = 0; i < _Rows; i++)
            _Data[i] = new char*[_Columns];

        for(dword i = 0; i < _Rows; i++) {
            for(dword j = 0; j < _Columns; j++) {
                dword len = fh->Get<word>();
                if(len == 0) {
                    _Data[i][j] = NULL;
                    continue;
                } // if len
                _Data[i][j] = new char[len+1];
                fh->Read(_Data[i][j], len, 1);
                _Data[i][j][len] = 0;
            } // for j
        } // for i

        fh->Close();
        delete fh;
        return true;
    } // bool
コード例 #2
0
ファイル: Quests.cpp プロジェクト: randybatiquin/freerose
void CWorldServer::ReadQSD(strings path, dword index)
{
    //LMA: mass exporter.
    bool lma_export=false;
    if(Config.massexport)
        lma_export=true;

	CRoseFile* fh = new CRoseFile(path, FM_READ | FM_BINARY);
	if(fh->IsOpen())
	{ // goto done;

        // Log(MSG_LOAD, "Loading %s", path); /* Commenting out this line, replacing MSG_LOAD with MSG_DEBUG -Terr0risT */
		//Log(MSG_DEBUG, "Loading %s", path);

        fh->Seek(4, SEEK_CUR);
        dword BlockCount = fh->Get<dword>();

        if(lma_export)
        {
            LogSp(MSG_INFO, " ");
            LogSp(MSG_INFO, " ");

            if(BlockCount==0)
            {
                //LogSp(MSG_INFO, "Exporting %s :: 0 block", path);
            }
            else if (BlockCount==1)
            {
                //LogSp(MSG_INFO, "Exporting %s :: 1 block", path);
            }
            else
            {
                //LogSp(MSG_INFO, "Exporting %s :: %i blocks", path,BlockCount);
            }

            //LogSp(MSG_INFO, "{");

        }

        fh->Seek(fh->Get<word>(), SEEK_CUR);
        for(dword i = 0; i < BlockCount; i++)
        {
            dword RecordCount = fh->Get<dword>();

            if(lma_export)
            {
                if(i>0)
                    //LogSp(MSG_INFO, "\t ");

                if(RecordCount==0)
                {
                    //LogSp(MSG_INFO, "\t Block %i / %i :: 0 Function",i+1,BlockCount);
                }
                else if (RecordCount==1)
                {
                    //LogSp(MSG_INFO, "\t Block %i / %i :: 1 Function",i+1,BlockCount);
                }
                else
                {
                   // LogSp(MSG_INFO, "\t Block %i / %i :: %i Functions",i+1,BlockCount,RecordCount);
                }

                //LogSp(MSG_INFO, "\t {");

            }

            fh->Seek(fh->Get<word>(), SEEK_CUR);
            for(dword j = 0; j < RecordCount; j++)
            {
                CQuestTrigger* trigger = new CQuestTrigger();
                trigger->id=((index*0x10000)+(i*0x100)+j);
                trigger->CheckNext = fh->Get<byte>();
                trigger->ConditionCount = fh->Get<dword>();
                trigger->ActionCount = fh->Get<dword>();

                dword len = fh->Get<word>();
                trigger->TriggerName = new char[len+1];
                fh->Read(trigger->TriggerName, len, 1);
                trigger->TriggerName[len] = 0;

                if(lma_export)
                {
                    char bactions[20];
                    char bconditions[20];

                    if(trigger->ConditionCount==0)
                    {
                        sprintf(bconditions,"0 condition");
                    }
                    else if(trigger->ConditionCount==1)
                    {
                        sprintf(bconditions,"1 condition");
                    }
                    else
                    {
                        sprintf(bconditions,"%i conditions",trigger->ConditionCount);
                    }

                    if(trigger->ActionCount==0)
                    {
                        sprintf(bactions,"0 action");
                    }
                    else if(trigger->ActionCount==1)
                    {
                        sprintf(bactions,"1 action");
                    }
                    else
                    {
                        sprintf(bactions,"%i actions",trigger->ActionCount);
                    }

                   // if(j>0)
                        //LogSp(MSG_INFO, "\t\t ");

                    //LogSp(MSG_INFO, "\t\t Function %i / %i (%s / %u) :: %s, %s",j+1,RecordCount,trigger->TriggerName,MakeStrHash(trigger->TriggerName),bconditions,bactions);
                    //if(trigger->CheckNext)
                        //LogSp(MSG_INFO, "\t\t\t <If Function %s returns False, we'll check the next Function (check_next activated)>",trigger->TriggerName);
                   // LogSp(MSG_INFO, "\t\t {");
                }

                if(trigger->ConditionCount > 0)
                {
                    if(lma_export)
                    {
                       // LogSp(MSG_INFO, "\t\t\t Conditions (%i)",trigger->ConditionCount);
                       // LogSp(MSG_INFO, "\t\t\t {");
                    }

                    trigger->Conditions = new CQuestTrigger::SQuestDatum*[trigger->ConditionCount];
                    for(dword k = 0; k < trigger->ConditionCount; k++)
                    {
                        CQuestTrigger::SQuestDatum* data = new CQuestTrigger::SQuestDatum();
                        data->size = fh->Get<int>();
                        data->opcode = fh->Get<int>();
                        data->data = new byte[data->size - 8];
                        fh->Read(data->data, data->size - 8, 1);
                        trigger->Conditions[k] = data;

                        //LMA: Export
                        if (lma_export)
                        {
                            //ExportQSDData(data->data,data->opcode,data->size,data);
                            ExportQSDData(data->data,data->size,data->opcode);
                        }

                    }

                    if(lma_export)
                    {
                       // LogSp(MSG_INFO, "\t\t\t }");
                    }

                }
                else
                {
                    if(lma_export)
                    {
                      //  LogSp(MSG_INFO, "\t\t\t 0 Condition");
                    }

                    trigger->Conditions = NULL;
                }

                if(trigger->ActionCount > 0)
                {
                    trigger->Actions = new CQuestTrigger::SQuestDatum*[trigger->ActionCount];
                    if(lma_export)
                    {
                        //LogSp(MSG_INFO, "\t\t\t Actions (%i)",trigger->ActionCount);
                        //LogSp(MSG_INFO, "\t\t\t {");
                    }

                    for(dword k = 0; k < trigger->ActionCount; k++)
                    {
                        CQuestTrigger::SQuestDatum* data = new CQuestTrigger::SQuestDatum();
                        data->size = fh->Get<int>();
                        data->opcode = fh->Get<int>() - 0x01000000;
                        data->data = new byte[data->size - 8];
                        fh->Read(data->data, data->size - 8, 1);
                        trigger->Actions[k] = data;

                        //LMA: Export
                        if (lma_export)
                        {
                            ExportQSDDataA(data->data,data->size,data->opcode);
                        }

                    }

                    if(lma_export)
                    {
                      //  LogSp(MSG_INFO, "\t\t\t }");
                    }

                }
                else
                {
                    if(lma_export)
                    {
                      //  LogSp(MSG_INFO, "\t\t\t 0 Action");
                    }

                    trigger->Actions = NULL;
                }

                trigger->TriggerHash = MakeStrHash(trigger->TriggerName);
                TriggerList.push_back( trigger );

                if(lma_export)
                {
                   // LogSp(MSG_INFO, "\t\t ");
                  //  LogSp(MSG_INFO, "\t\t }");
                }

            }

            if(lma_export)
            {
               // LogSp(MSG_INFO, "\t ");
               // LogSp(MSG_INFO, "\t }");
            }

        }

        if(lma_export)
        {
           // LogSp(MSG_INFO, " ");
           // LogSp(MSG_INFO, "}");
        }

    }
    else
    {
         //Log( MSG_ERROR, "QSD File: '%s'", path );
         //Log( MSG_WARNING, "QSD File: '%s'", path );
		 Log( MSG_ERROR, "Could not open QSD File: '%s'", path );
    }

    fh->Close();
	delete fh;
}
コード例 #3
0
ファイル: Quests.cpp プロジェクト: RavenX8/osirose
void CWorldServer::ReadQSD(strings path, dword index){	
	string	tmp("3DData/QUESTDATA/");
	while (*++path != '\\');
	while (*++path != '\\');
	while (*path != 0)
		tmp.push_back(tolower(*++path));
	/* Log(MSG_INFO, "Openning : %s", tmp.c_str()); */
	CRoseFile* fh = new CRoseFile(tmp.c_str(), FM_READ | FM_BINARY);
	if(fh->IsOpen()) { // goto done;

	Log(MSG_LOAD, "Loading %s                              ", tmp.c_str());

	fh->Seek(4, SEEK_CUR);
	dword BlockCount = fh->Get<dword>();
	fh->Seek(fh->Get<word>(), SEEK_CUR);
	for(dword i = 0; i < BlockCount; i++){
		dword RecordCount = fh->Get<dword>();
		fh->Seek(fh->Get<word>(), SEEK_CUR);
		for(dword j = 0; j < RecordCount; j++){
			CQuestTrigger* trigger = new CQuestTrigger();
			trigger->id=((index*0x10000)+(i*0x100)+j);
			trigger->CheckNext = fh->Get<byte>();
			trigger->ConditionCount = fh->Get<dword>();
			trigger->ActionCount = fh->Get<dword>();
			dword len = fh->Get<word>();
			trigger->TriggerName = new char[len+1];
			fh->Read(trigger->TriggerName, len, 1);
			trigger->TriggerName[len] = 0;

			if(trigger->ConditionCount > 0){
				trigger->Conditions = new CQuestTrigger::SQuestDatum*[trigger->ConditionCount];
				for(dword k = 0; k < trigger->ConditionCount; k++){
					CQuestTrigger::SQuestDatum* data = new CQuestTrigger::SQuestDatum();
					data->size = fh->Get<int>();
					data->opcode = fh->Get<int>();
					data->data = new byte[data->size - 8];
					fh->Read(data->data, data->size - 8, 1);
					trigger->Conditions[k] = data;
				}
			}else{
				trigger->Conditions = NULL;
			}

			if(trigger->ActionCount > 0){
				trigger->Actions = new CQuestTrigger::SQuestDatum*[trigger->ActionCount];
				for(dword k = 0; k < trigger->ActionCount; k++){
					CQuestTrigger::SQuestDatum* data = new CQuestTrigger::SQuestDatum();
					data->size = fh->Get<int>();
					data->opcode = fh->Get<int>() - 0x01000000;
					data->data = new byte[data->size - 8];
					fh->Read(data->data, data->size - 8, 1);
					trigger->Actions[k] = data;
				}
			}else{
				trigger->Actions = NULL;
			}

			trigger->TriggerHash = MakeStrHash(trigger->TriggerName);
			TriggerList.push_back( trigger );
		}
	}
}else
     Log( MSG_ERROR, "QSD File: '%s'", tmp.c_str() );
     
    fh->Close();
	delete fh;
}