Jump to content

flygun

Former Staff
  • Posts

    729
  • Joined

  • Last visited

  • Days Won

    7
  • Feedback

    0%

Posts posted by flygun

  1. hello guys i wrote this script to help using makepack

    import glob, os , shutil, sys
    from os import path , system
    executefile = "execute.cmd"
    logfolder = "logs"
    packfile = "D:\Husam\Client\pack/"
    packedfolder = "packed/"
    text = ".txt"
    ivfilename = ""
    type = ""
    comptype = ""
    file_list = []
    def yes_no(question, default="yes"):
    	valid = {"yes": True, "y": True, "ye": True, "no": False, "n": False}
    	if default is None:
    		prompt = " [y/n] "
    	elif default == "yes":
    		prompt = " [Y/n] "
    	elif default == "no":
    		prompt = " [y/N] "
    	else:
    		raise ValueError("invalid default answer: '%s'" % default)
    
    	
    	sys.stdout.write(question + prompt)
    	choice = raw_input().lower()
    	if default is not None and choice == '':
    		return valid[default]
    	if choice in valid:
    		return valid[choice]
    	else:
    		sys.stdout.write("Please respond with 'yes' or 'no' ", "(or 'y' or 'n').\n")
    
    def get_size(dirname):
    	total_size = 0
    	for dirpath, dirnames, filenames in os.walk(dirname):
    		for f in filenames:
    			fp = os.path.join(dirpath, f)
    			total_size += os.path.getsize(fp)
    	return total_size
    	
    def createpack(filename, dirname):
    	if get_size(dirname) == 0:
    		print("This is an empty folder [%s]"% (dirname))
    		exit()
    	print("Please Chose the type of pack you want to create\n")
    	print("1:CompressExtNameList --> type 1")
    	print("2:SecurityExtNameList --> type 2")
    	print("3:panamaextnamelist --> type 3")
    	print("4:cshybridencryptexenamelist --> type 4\n")
    	type = raw_input("Your Choice:")
    	type = int(type)
    	if type < 0 or type > 4:
    		print ("Please Type one number Bettwen 1 - 5")
    	if type == 1:
    		comptype = "CompressExtNameList";
    	if type == 2:
    		comptype = "SecurityExtNameList";
    	if type == 3:
    		comptype = "panamaextnamelist";
    	if type == 4:
    		comptype = "cshybridencryptexenamelist";
    	makeit = filename + text
    	check(makeit,1,"no")
    	x = open(makeit, 'w')
    	x.write("FolderName\t\"%s\"\nPackName\t\"%s\"\n"% (packedfolder, filename))
    	if type == 3:
    		pack = os.path.join(packfile,filename)
    		check(pack,0,"yes")
    		x.write("IV\t\"%s\"\n"% (pack))
    	x.write("\nList\t%s\n{\n" % (comptype))
    	chkdict = {}
    	setdef = chkdict.setdefault
    	for root, dirs, files in os.walk(dirname):
    		for file in files:
    			ext = path.splitext(file)[1]
    			if not ext in chkdict:
    				x.write("\t\"%s\"\n" % setdef(ext,ext))
    	del chkdict
    	x.write("}\n")
    	x.write("\nList\tFilelist\n{\n")
    	for root, dirs, files in os.walk(dirname):
    		for filesname in files :
    			filepath = os.path.join(root,filesname)
    			if os.stat(filepath).st_size==0:
    				continue
    			x.write("\t\"%s\"\n" %(filepath))
    	x.write("}\n")
    
    def	extract_writer(type, iv):
    	global ivfilename , file_list
    	check("",0,"no")
    	if not os.listdir(packfile): 
    		print("Error: %s folder is empty \nsystem will close the script now"%(packfile))
    		system("pause")# this is an optinal command if you want to see what is going on
    		return
    	listofpacks()
    	pack = raw_input("Pack Number:")
    	pack = int(pack)
    	file = file_list[pack]
    	index = file + ".eix"
    	y = check(index,0,"no")
    	if y == True:
    		file2 = os.path.join(packfile,file)
    		if iv == True:
    			ivfilename = file2
    		x = open(executefile, 'a') #open extract.cmd
    		x.write("MakePack.exe --%s %s %s\t> logs/%s_log.txt\t 2> logs/%s_error.txt\n" % (type,file2, ivfilename, file, file))
    		print("MakePack.exe --%s %s %s\n" % (type,file2, ivfilename)) #show you on screen what are the file 
    	else:
    		return
    	x.close()
    	executeMakePackfiles(executefile)
    	
    def check(filename,remove,IVa="no"):
    	if filename == ""  and remove == 0:
    		if os.path.isfile(executefile):
    			os.remove(executefile)
    		if not os.path.isdir(logfolder):
    			os.system("mkdir %s" % (logfolder))
    		if not os.path.isdir(packfile):
    			os.system("mkdir pack")
    		return True
    	elif os.path.splitext(filename)[1] == ".eix":
    		filename = os.path.join(packfile,filename)
    		if os.path.isfile(filename):
    			return True
    		print("[%s] Is missing"%(filename))
    		return False
    	if filename != "":
    		if os.path.isfile(filename) or os.path.isdir(filename):
    			if remove == 1:
    				os.remove(filename)
    			if IVa == "yes":
    				os.system("MakePack.exe --createiv %s"%(filename))
    
    #run extract.cmd to execute the commands
    def	executeMakePackfiles(filename):
    	answer = yes_no("Do you Want to run %s?" %(filename),"yes")
    	if True == answer:
    		if filename == executefile:
    			os.system(executefile)
    		else:
    			os.system("MakePack.exe %s" %(filename))
    	else:
    		system("pause")# this is an optinal command if you want to see what is going on
    	main()
    
    def listofpacks():
    	global file_list
    	i = 0
    	file_count = len(glob.glob("%s*.epk"%(packfile)))
    	for file in glob.glob("%s*.epk"%(packfile)): #search for any file with the (.epk) extention
    		file = path.basename(file)
    		file = path.splitext(file)[0] #removeing extention [xxx.epk ---> xxx (without (.epk))]
    		file_list.append(file)
    		#
    	while i < file_count:
    		filo = file_list[i]
    		filo = ("%d:%s" % (i,filo))
    		print filo
    		i += 1
    
    def cls():
    	os.system("cls")
    
    def main():
    	print ("Hello This is Make Pack pythn tool")
    	print ("type the number of the command you want to execute")
    	print ("1:Create-iv\n2:Open-iv\n3:Extract\n4:Extract With Iv\n5:Make Pack\n6:Exit")
    	choice = raw_input("Your Choice:")
    	choice = int(choice)
    	if choice < 1 or choice > 6:
    		print ("Please Type one number Bettwen 1 - 6")
    	if choice >= 1 and choice <= 4:
    		if choice == 1:
    			executetype = "createiv"
    			iv = bool(False)
    		elif choice == 2:
    			executetype = "openiv"
    			iv = bool(False)
    		elif choice == 3:
    			executetype = "extract"
    			iv = bool(False)
    		elif choice == 4:
    			executetype = "extract"
    			iv = bool(True)
    		cls()
    		extract_writer(executetype, iv)
    	if choice == 5:
    		packname = raw_input("Pack Name:")
    		path = raw_input("Path:")
    		createpack(packname,path)
    		packname2 = packname + text
    		executeMakePackfiles(packname2)
    		system("pause")# this is an optinal command if you want to see what is going on
    		main()
    	if choice == 6:
    		exit()
    main()
    
    

     

    now I'm not a python expert so if any expert here can tell me some notes on how to write better code it would very nice

    plus if any one want my version of make pack just tell me to upload it

    now my only problem here is that thae script writes only one type of compressing types using by the binary

    i you can't use the script to write something like this fro example  YET

    List	SecurityExtNameList
    {
    	".dds"
    	".tga"
    	".jpg"
    }
    List	Panamaextnamelist
    {
    	".msenv"
    	".sub"
    }

    but anyway the script generates something look like this

    FolderName	"packed"
    PackName	"etc"
    
    List	SecurityExtNameList
    {
    	".msenv"
    	".dds"
    	".tga"
    	".sub"
    	".jpg"
    }
    
    List	Filelist
    {
    	"ymir work\environment\a1.msenv"
    	"....."
    }

    #Updated with IV file check for panama type .. thanks to metin2team for noticing the mistake 

    #updated with file size check ... ---> make pack wont pack 0 sized  file  so the script ignores the 0 file :)

    #updated ... now after any command you do the script restarts from the beginning ...because the python window closes after the code is done

    #update --> now you can specify the pack

    • Good 1
    • Love 4
  2. hello guys ... i'm asking if there is a function which generate the index content

    at the moment i'm using MakePack (own compiled) with some python scripts to help me but my point is i've created a new function in makepack project... i called it "MakePackFile" to be more specific 

    void MakePackFile(const char * filename, int type)
    {
    	if (type < COMPRESSED_TYPE_COMPRESS || 
    		type > COMPRESSED_TYPE_HYBRIDCRYPT)
    		type = COMPRESSED_TYPE_SECURITY;
    	const char* comptype;
    	if (type == 1)
    		comptype = "CompressExtNameList";
    	if (type == 2)
    		comptype = "SecurityExtNameList";
    	if (type == 3)
    		comptype = "panamaextnamelist";
    	if (type == 4)
    		comptype = "cshybridencryptexenamelist";
    	boost::filesystem::path p(filename);
    	string extension = ".txt";
    	std::string path = p.stem().string();
    	ofstream myfile((path + extension).c_str());
    	myfile << "FolderName\t\"packed\"\n";
    	myfile << "PackName\t" << p.stem() << "\n";
    
    	myfile << "\nList\t" << comptype << "\n{\n";
    	myfile << "\t\"" << "\"\n"; // <--- type all extinsion included in thje pack 
    	myfile << "}\n\n";
    	myfile << "\nList\tFilelist\n{\n";
    	myfile << "\t\"" << "\"\n";
    	myfile << "}\n";
    	myfile << "List\tFileList\n{\n";
    	myfile << "\t\"" << "\"\n";// <--- type file name .. try to take it from "CEterPack::Extract()" function
    
    }

    now my goal is to check the type of the pack and send it to this function like this

    	else if (!strcmp(argv[1], "--extract"))
    	{
    		// .exe --extract <packname> [<IV filename>]
    		if (argc < 3)
    		{
    			printf("Usage: %s --extract <packname> [<IV filename>]\n", argv[0]);
    			return 1;
    		}
    
    		CMappedFile file;
    		const BYTE* iv = NULL;
    
    		if (argc >= 4)
    		{
    			if (!file.Create(argv[3], (const void**)&iv, 0, 32))
    			{
    				printf("Cannot load IV file %s\n", argv[3]);
    				return 1;
    			}
    		}
    		CEterPack pack;
    		CEterFileDict dict;
    		if (pack.Create(dict, argv[2], "", true, iv))
    		{
    			pack.Extract();
    			MakePackFile(argv[2], X);//argv[2] = name of the pack
    			                         //x = type of pack 
    			return 0;
    		}
    
    		printf("Cannot extract pack %s\n", argv[2]);
    		return 1;
    	}

     

  3. OMG i'm soo stupid ... i forgot that this topic i about infinity arrows i just saw night's comment

    so it can be written like this

    void CHARACTER::UseArrow(LPITEM pkArrow, DWORD dwArrowCount)
    {
    	DWORD dwVnum = pkArrow->GetVnum();
    }

     

  4. open "char_battle.cpp" from game folder in server source and search for

    void CHARACTER::UseArrow(LPITEM pkArrow, DWORD dwArrowCount)

    it'll be like this

    void CHARACTER::UseArrow(LPITEM pkArrow, DWORD dwArrowCount)
    {
        int iCount = pkArrow->GetCount();
        DWORD dwVnum = pkArrow->GetVnum();
        iCount = iCount - MIN(iCount, dwArrowCount);
        pkArrow->SetCount(iCount);
    
        if (iCount == 0)
        {
            LPITEM pkNewArrow = FindSpecifyItem(dwVnum);
    
            sys_log(0, "UseArrow : FindSpecifyItem %u %p", dwVnum, get_pointer(pkNewArrow));
    
            if (pkNewArrow)
                EquipItem(pkNewArrow);
        }
    }

    make it look like this

    void CHARACTER::UseArrow(LPITEM pkArrow, DWORD dwArrowCount)
    {
        int iCount = pkArrow->GetCount();
        DWORD dwVnum = pkArrow->GetVnum();
        if (iCount == 0)
        {
            LPITEM pkNewArrow = FindSpecifyItem(dwVnum);
    
            sys_log(0, "UseArrow : FindSpecifyItem %u %p", dwVnum, get_pointer(pkNewArrow));
    
            if (pkNewArrow)
                EquipItem(pkNewArrow);
        }
    }

     

    btw this :

        if (iCount == 0)
        {
            LPITEM pkNewArrow = FindSpecifyItem(dwVnum);
    
            sys_log(0, "UseArrow : FindSpecifyItem %u %p", dwVnum, get_pointer(pkNewArrow));
    
            if (pkNewArrow)
                EquipItem(pkNewArrow);
        }

    is basicly mmmmmmm useless

    yeah it/s useless but this is not useless

    if (pkNewArrow)
                EquipItem(pkNewArrow);

    it'll attach new group of arrows when the first count to 0 :) so it can be written like this

    void CHARACTER::UseArrow(LPITEM pkArrow, DWORD dwArrowCount)
    {
        int iCount = pkArrow->GetCount();
        DWORD dwVnum = pkArrow->GetVnum();
        LPITEM pkNewArrow = FindSpecifyItem(dwVnum);
        if (iCount == 0)
            if (pkNewArrow)
                EquipItem(pkNewArrow);
    }

     

  5. i have every timy the same error on compile need help pleass 

     

     will break strict-aliasing rules
    compile gm.cpp
    gm.cpp: In function 'BYTE gm_new_get_level(const char*, const char*, const char*)':
    gm.cpp:69: warning: suggest parentheses around && within ||
    compile guild.cpp
    guild.cpp: In member function 'void CGuild::SendListOneToAll(DWORD)':
    guild.cpp:407: error: 'struct TGuildMemberPacketData' has no member named 'byNameFlag'
    guild.cpp:408: error: 'struct TGuildMemberPacketData' has no member named 'byGrade'
    guild.cpp:409: error: 'struct TGuildMemberPacketData' has no member named 'byIsGeneral'
    guild.cpp:410: error: 'struct TGuildMemberPacketData' has no member named 'byJob'
    guild.cpp:412: error: 'struct TGuildMemberPacketData' has no member named 'dwOffer'
    guild.cpp: In member function 'void CGuild::SendListPacket(CHARACTER*)':
    guild.cpp:459: error: 'struct TGuildMemberPacketData' has no member named 'byNameFlag'
    guild.cpp:460: error: 'struct TGuildMemberPacketData' has no member named 'byGrade'
    guild.cpp:461: error: 'struct TGuildMemberPacketData' has no member named 'byIsGeneral'
    guild.cpp:462: error: 'struct TGuildMemberPacketData' has no member named 'byJob'
    guild.cpp:464: error: 'struct TGuildMemberPacketData' has no member named 'dwOffer'
    guild.cpp: In member function 'bool CGuild::OfferExp(CHARACTER*, int)':
    guild.cpp:983: error: 'struct TGuildMemberPacketData' has no member named 'byNameFlag'
    guild.cpp:984: error: 'struct TGuildMemberPacketData' has no member named 'byGrade'
    guild.cpp:985: error: 'struct TGuildMemberPacketData' has no member named 'byIsGeneral'
    guild.cpp:986: error: 'struct TGuildMemberPacketData' has no member named 'byJob'
    guild.cpp:988: error: 'struct TGuildMemberPacketData' has no member named 'dwOffer'
    guild.cpp: In member function 'void CGuild::LevelChange(DWORD, int)':
    guild.cpp:1664: error: 'struct TGuildMemberPacketData' has no member named 'byNameFlag'
    guild.cpp:1665: error: 'struct TGuildMemberPacketData' has no member named 'byGrade'
    guild.cpp:1666: error: 'struct TGuildMemberPacketData' has no member named 'byIsGeneral'
    guild.cpp:1667: error: 'struct TGuildMemberPacketData' has no member named 'byJob'
    guild.cpp:1669: error: 'struct TGuildMemberPacketData' has no member named 'dwOffer'
    guild.cpp: In member function 'void CGuild::ChangeMemberData(DWORD, DWORD, int, BYTE)':
    guild.cpp:1706: error: 'struct TGuildMemberPacketData' has no member named 'byNameFlag'
    guild.cpp:1707: error: 'struct TGuildMemberPacketData' has no member named 'byGrade'
    guild.cpp:1708: error: 'struct TGuildMemberPacketData' has no member named 'byIsGeneral'
    guild.cpp:1709: error: 'struct TGuildMemberPacketData' has no member named 'byJob'
    guild.cpp:1711: error: 'struct TGuildMemberPacketData' has no member named 'dwOffer'
    ../../../Extern/include/cryptopp/cryptlib.h: In member function 'bool CryptoPP::NameValuePairs::GetValue(const char*, T&) const [with T = std::string]':
    ../../../Extern/include/cryptopp/cryptlib.h:277:   instantiated from here
    ../../../Extern/include/cryptopp/cryptlib.h:264: warning: dereferencing type-punned pointer will break strict-aliasing rules
    ../../../Extern/include/cryptopp/cryptlib.h: In member function 'bool CryptoPP::NameValuePairs::GetValue(const char*, T&) const [with T = int]':
    ../../../Extern/include/cryptopp/cryptlib.h:283:   instantiated from here
    ../../../Extern/include/cryptopp/cryptlib.h:264: warning: dereferencing type-punned pointer will break strict-aliasing rules
    Makefile:119: recipe for target 'OBJDIR/guild.o' failed
    gmake[1]: *** [OBJDIR/guild.o] Error 1
    gmake[1]: Leaving directory '/root/workspace/Server/game/src'
    Makefile:60: recipe for target 'all' failed
    gmake: *** [all] Error 2
    root@root:~/workspace/Server #

     

    re do the server guild part

  6. open "char_battle.cpp" from game folder in server source and search for

    void CHARACTER::UseArrow(LPITEM pkArrow, DWORD dwArrowCount)

    it'll be like this

    void CHARACTER::UseArrow(LPITEM pkArrow, DWORD dwArrowCount)
    {
        int iCount = pkArrow->GetCount();
        DWORD dwVnum = pkArrow->GetVnum();
        iCount = iCount - MIN(iCount, dwArrowCount);
        pkArrow->SetCount(iCount);
    
        if (iCount == 0)
        {
            LPITEM pkNewArrow = FindSpecifyItem(dwVnum);
    
            sys_log(0, "UseArrow : FindSpecifyItem %u %p", dwVnum, get_pointer(pkNewArrow));
    
            if (pkNewArrow)
                EquipItem(pkNewArrow);
        }
    }

    make it look like this

    void CHARACTER::UseArrow(LPITEM pkArrow, DWORD dwArrowCount)
    {
        int iCount = pkArrow->GetCount();
        DWORD dwVnum = pkArrow->GetVnum();
        if (iCount == 0)
        {
            LPITEM pkNewArrow = FindSpecifyItem(dwVnum);
    
            sys_log(0, "UseArrow : FindSpecifyItem %u %p", dwVnum, get_pointer(pkNewArrow));
    
            if (pkNewArrow)
                EquipItem(pkNewArrow);
        }
    }

     

    • Love 1
  7. The key should be M(Message).

    def __PressMKey(self):
            if (app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL)):
                    if (interfaceModule.IsWhisperHide == 0):
                            self.interface.HideAllWhisperButton()
                            interfaceModule.IsWhisperHide = 1			
                    else:
                            self.interface.ShowAllWhisperButton()
                            interfaceModule.IsWhisperHide = 0			

    Kind Regards

    Ken

    and attack must be with A not with space ... my point it's doesn't matter P ~ Q ~ R ... or whatever :P

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.