Jump to content

Stuff I Found on my HDD


Recommended Posts

  • Former Staff

M2 Download Center

This is the hidden content, please
( Internal )

Rather than having this crap die in my HDD I've decided to share them, they range around 2017-2018

 

utils.h optimizations (You need a c++11 compiler)

utils.h

//Replace:
out = (long long) strtoull(in, NULL, 10);
//To:
out = strtoll(in, NULL, 10);

//Replace:
out = (unsigned long) strtoul(in, NULL, 10);
//To:
out = strtoul(in, NULL, 10);
//Replace:
out = (long) strtol(in, NULL, 10);
//To:
out = strtol(in, NULL, 10);



//Add:
inline bool str_to_number (unsigned long long& out, const char *in)
{
 if (0==in || 0==in[0]) return false;

 out = strtoull(in, NULL, 10);
 return true;
}

Useless check in char.cpp

//From:
			if(val==0 && val>0)
				pack.value = val;
			else
				pack.value = val;
//To:
pack.value = val;

 

 

Random stuff: Colored console messages (Windows only - you can do a nix version by using ansii colors) - this code was made in 2017, the quality definitly shows as it could be extended or make a singular API for console (working for both nix and win)

Sample usage:

#include "../libthecore/include/winconsole.h"

void test_console() {
    winconsole_set_color(CONSOLE_COLOR_GREEN); //This set the color
    //You can find the list of all usable color in winconsole.h
    printf("Test WinConsole\n"); //Print the text with the new color
    winconsole_resetcolor(); //Always reset color else the console will continue print the same color
    printf("No color\n"); //Print with default color (WHITE)
}

 

winconsole.h (libthecore/include)

/* ---------------------------------
	ARVES100 WinConsole
	Required for colored console
------------------------------------ */
#ifndef _ARVES100_INCLUDE_WINCONSOLE_HEADER_C_
#define _ARVES100_INCLUDE_WINCONSOLE_HEADER_C_

#define CONSOLE_COLOR_BLACK 0
#define CONSOLE_COLOR_RED 4
#define CONSOLE_COLOR_BLUE 9
#define CONSOLE_COLOR_WHITE 15
#define CONSOLE_COLOR_GREEN 10
#define CONSOLE_COLOR_YELLOW 14
#define CONSOLE_COLOR_PURPLE 13

int winconsole_initialize();
void winconsole_resetcolor();
void winconsole_setcolor(int color);
void winconsole_pause();

#endif

winconsole.c (libthecore/src)

/*
	ARVES100 COLORED CONSOLE FOR WIN32
	CODED 06.01.2017
*/

#include "stdafx.h"

#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__)

#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>

#include "winconsole.h"

FILE* fp = NULL;
HANDLE StdOut = NULL;

int winconsole_initialize() {
	StdOut = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(StdOut,CONSOLE_COLOR_WHITE);
	return 0;
}

void winconsole_resetcolor() {
	SetConsoleTextAttribute(StdOut, CONSOLE_COLOR_WHITE);
}

void winconsole_setcolor(int color) {
	SetConsoleTextAttribute(StdOut, color);
}

void winconsole_pause() {
	// Alternativa portatile usando scanf+printf (cstdio)
	printf("Press any key to continue...");
	char ch;
	scanf("%1c",&ch);
}

#endif

 

Example usage on log.c (libthecore)

/********************************************************/
/* COLORED CONSOLE FOR WIN32 (PRIVATE FREE SYSTEM)		*/
/* CODED BY ARVES100 (06/01/2017)						*/
/********************************************************/

//libthecore/src/log.c
#define SYSERR_FILENAME "syserr.txt"
#define PTS_FILENAME "PTS.txt"
#include "winconsole.h"
#endif
///////////////////////
#else
void _sys_err(const char *func, int line, const char *format, ...)
{
	va_list args;
	time_t ct = time(0);  
	char *time_s = asctime(localtime(&ct));

	char buf[1024 + 2]; // \n을 붙이기 위해..
	int len;

	if (!log_file_err)
		return;
	
	winconsole_setcolor(CONSOLE_COLOR_RED);

	time_s[strlen(time_s) - 1] = '\0';
	len = snprintf(buf, 1024, "SYSERR: %-15.15s :: %s: ", time_s + 4, func);
	buf[1025] = '\0';

	if (len < 1024)
	{
		va_start(args, format);
		vsnprintf(buf + len, 1024 - len, format, args);
		va_end(args);
	}

	strcat(buf, "\n");

	// log_file_err 에 출력
	fputs(buf, log_file_err->fp);
	fflush(log_file_err->fp);

	// log_file_sys 에도 출력
	fputs(buf, log_file_sys->fp);
	fflush(log_file_sys->fp);

	fputs(buf, stdout);
	fflush(stdout);
	
	winconsole_resetcolor();
}
#endif
///////////////////
void sys_log(unsigned int bit, const char *format, ...)
{
	va_list	args;

	if (bit != 0 && !(log_level_bits & bit))
		return;
	

	#ifdef __WIN32__
		winconsole_setcolor(CONSOLE_COLOR_BLUE);
	#endif

	if (log_file_sys)
	{
		time_t ct = time(0);  
		char *time_s = asctime(localtime(&ct));

		fprintf(log_file_sys->fp, sys_log_header_string);

		time_s[strlen(time_s) - 1] = '\0';
		fprintf(log_file_sys->fp, "%-15.15s :: ", time_s + 4);

		va_start(args, format);
		vfprintf(log_file_sys->fp, format, args);
		va_end(args);

		fputc('\n', log_file_sys->fp);
		fflush(log_file_sys->fp);
	}

#ifndef __WIN32__
	// log_level이 1 이상일 경우에는 테스트일 경우가 많으니 stdout에도 출력한다.
	if (log_level_bits > 1)
	{
#endif
		fprintf(stdout, sys_log_header_string);

		va_start(args, format);
		vfprintf(stdout, format, args);
		va_end(args);

		fputc('\n', stdout);
		fflush(stdout);
		
#ifndef __WIN32__
	}
#else
	winconsole_resetcolor();
#endif
}

 

Teamspeak 3 python interfaces

This was a leftover for an old system a pserver told me to make and then simply dropped the idea (TS3 SDK was too expensive)

this is what is left to, I don't have any source code in client side and I do not provide any support for this, it's just a working python interface that needs to be finished. Pretty much the same you would achieve if you unpack the root where this system was originally going to be.

This is the hidden content, please

 

XMLCreator updated

Who does remember the old XML files from Tim's archive? This is an updated version for Tim's 40k archiver that was based from a version of Tim's old 2089 archiver made by some guy on epvp.

This is the hidden content, please

You need ActionScript3 to build this.

 

Wrong comparison on char_skill.cpp:2635 (Required for clang)

 

from:

                    (NULL != pkVictim && SKILL_HORSE_WILDATTACK != dwVnum) ? pkVictim->GetVID() : NULL,
                    ComputeCooltime(iCooltime * 1000),

to:

                    (NULL != pkVictim && SKILL_HORSE_WILDATTACK != dwVnum) ? pkVictim->GetVID() : 0,
                    ComputeCooltime(iCooltime * 1000),

 

  • Metin2 Dev 14
  • Eyes 1
  • Angry 1
  • Good 2
  • Love 11

Everyday you wake up as a Metin2 developer is a bad day...

METIN1 src when

Link to comment
Share on other sites

Announcements



×
×
  • 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.