Jump to content
metin2dev
Ekstasia2
  • 0
Kori

open My System Error

Question

Hello Guys,

Here is my Mount system via txt ( Serverside ) but i have a little proplem. The txt dont load but i dont know why.

Here my char_mount.cpp:

#include "stdafx.h"

#include "char_mount.h"
#include "char.h"
#include "log.h"
#include <fstream>
#include <sstream>

std::vector <AddNewMountsStruct> MountObjectList;

void LoadNewMounts(const char *fileName)
{
	std::string strdwVnum;
	std::ifstream File(fileName);

	if (File.fail())
	{
		sys_err("%s not found", fileName);
		return;
	}

	MountObjectList.clear();
	AddNewMountsStruct preload;
	while (!File.eof())
	{
		File >> strdwVnum;
		preload.dwVnum = atoi(strdwVnum.c_str());
		MountObjectList.push_back(preload);
	}
	sys_log(1, "Datei geladen");
}

bool AddNewMounts(int dwVnum)
{
	for (unsigned int i = 0; i < MountObjectList.size(); i++){
		if (MountObjectList[i].dwVnum == dwVnum){
			return true;
		}
	}
	return false;
}

char_mount.h


struct AddNewMountsStruct{
	int dwVnum;
};

void LoadNewMounts(const char *fileName);
bool AddNewMounts(int dwVnum);

 

 

here the funktion from the main.cpp 

int main(int argc, char **argv) )

LoadNewMounts("Mounts.txt");

 

 

the Mounts.txt looks like
 

0 // Character DMG
101 // example Mount
102 // example Mount
103 // example Mount

 

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0
31 minutes ago, Shelby said:

for load the file dude,

char YourFileName[256+1];

snprintf(YourFileName, sizeof(YourFileName), "yourfilename.txt");

and open it, etc..

sorry i dont understand you now :/
 

 

edit:

 

My new main.cpp function:

 

LoadNewMounts();

 

char_mounts.h:
 

struct AddNewMountsStruct{
	int dwVnum;
};

void LoadNewMounts();
bool AddNewMounts(int dwVnum);

char_mount.cpp:

 

#include "stdafx.h"
#include "locale_service.h"
#include "char_mount.h"
#include "char.h"
#include "log.h"
#include <fstream>
#include <sstream>
using namespace std;

std::vector <AddNewMountsStruct> MountObjectList;

void LoadNewMounts()
{
	char szFileName[256];
	snprintf(szFileName, sizeof(szFileName), "%s/Mounts.txt", LocaleService_GetBasePath().c_str());
	string strdwVnum;
	ifstream File(szFileName);

	if (!File.is_open()) {
		fprintf(stderr, "Failed to Load  %s/Mounts.txt\n", LocaleService_GetBasePath().c_str());
		sys_err("Failed to  %s/Mounts.txt", LocaleService_GetBasePath().c_str());
		return;
	}

	MountObjectList.clear();
	AddNewMountsStruct preload;
	while (!File.eof())
	{
		File >> strdwVnum;
		preload.dwVnum = atoi(strdwVnum.c_str());
		MountObjectList.push_back(preload);
	}
	sys_log(1, "Datei geladen");
}

bool AddNewMounts(int dwVnum)
{
	for (unsigned int i = 0; i < MountObjectList.size(); i++){
		if (MountObjectList[i].dwVnum == dwVnum){
			return true;
		}
	}
	return false;
}

 

Share this post


Link to post
Share on other sites
  • 0

for load the file dude,

char YourFileName[256+1];

snprintf(YourFileName, sizeof(YourFileName), "yourfilename.txt");

and open it, etc..

Share this post


Link to post
Share on other sites
  • 0
1 minute ago, Shelby said:

no

int dwVnum;

DWORD dwVnum;

:facepalm:

the mount is an int the dwVnum is not relevant

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×