Post Pacific  

Go Back   Post Pacific > Lineage 2 > Lineage 2 Server Modifications ONLY!
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 07.06.2006, 12:15   #16
testdude
Архивный участник
 
Join Date: Nov 2005
Posts: 504
Default

well, for those who are interested in making their own dll's, i got some stuff too ;o
Code:
int RequestMakeMacroPacket(DWORD hSocket, unsigned char* hBuffer)
{
	DWORD id;
	unsigned char icon;
	unsigned char count;
	wchar_t name[255];
	wchar_t desc[255];
	wchar_t acr[255];

	unsigned char buf[4095];
	unsigned char entry;
	unsigned char type;
	DWORD skill;
	unsigned char shortcut;
	wchar_t cmd[1023];
	bool bEditMode = false;

	MACRO *pMacroAux;

	int charId = GetCharIDFromSocket(hSocket);
	if (charId == NULL)
		return 1;

	Disassemble(hBuffer, FMT_REQUEST_MAKE_MACRO_MAIN, &id, 64, name, 64, desc, 64, acr, &icon, &count, 4095, buf);
	

	unsigned short i;
	for (i = 0; i < pInfoTable[charId]->macro_list.size(); i++)
	{
		if (pInfoTable[charId]->macro_list[i]->id == id)
		{
			bEditMode = true;

			break;
		}
	}

	pInfoTable[charId]->macro_rev++;

	if (bEditMode)
		pMacroAux = pInfoTable[charId]->macro_list[i];
	else
		pMacroAux = (MACRO *)malloc(sizeof(MACRO));
 
	pMacroAux->id = id;
	pMacroAux->count = count;
	pMacroAux->icon = icon;

	if (bEditMode)
	{
		pMacroAux->name = (wchar_t *)realloc(pMacroAux->name, (wcslen(name)+2) * sizeof(wchar_t));
		pMacroAux->desc = (wchar_t *)realloc(pMacroAux->desc, (wcslen(desc)+2) * sizeof(wchar_t));
		pMacroAux->acr = (wchar_t *)realloc(pMacroAux->acr, (wcslen(acr)+2) * sizeof(wchar_t));
	}	
	else
	{
		pMacroAux->name = (wchar_t *)malloc((wcslen(name)+2) * sizeof(wchar_t));
		pMacroAux->desc = (wchar_t *)malloc((wcslen(desc)+2) * sizeof(wchar_t));
		pMacroAux->acr = (wchar_t *)malloc((wcslen(acr)+2) * sizeof(wchar_t));
	}

	wcscpy(pMacroAux->name, name);
	wcscpy(pMacroAux->desc, desc);
	wcscpy(pMacroAux->acr, acr);

	if (bEditMode)
	{
		for (short j = 0; j < pMacroAux->count; j++)
			free(pMacroAux->cmds[j].cmd);

		free(pMacroAux->cmds);
	}

	pMacroAux->cmds = (MACRO_CMD *)malloc(sizeof(MACRO_CMD)*count);

	size_t x = 0;
	for (short i = 0; i < count; i++)
	{
		Disassemble(buf + x, FMT_REQUEST_MAKE_MACRO_ELEM, &entry, &type, &skill, &shortcut, 1023, cmd);

		pMacroAux->cmds[i].cmd = (wchar_t *)malloc((wcslen(cmd)+2) * sizeof(wchar_t));
		wcscpy(pMacroAux->cmds[i].cmd, cmd);
		
		pMacroAux->cmds[i].id = id;
		pMacroAux->cmds[i].shortcut = shortcut;
		pMacroAux->cmds[i].skill = skill;
		pMacroAux->cmds[i].type = type;
		
		x += ((wcslen(cmd) + 1)*sizeof(wchar_t) + 1 + 1 + 4 + 1);
	}

	if (!bEditMode)
		pInfoTable[charId]->macro_list.push_back(pMacroAux);

	SendMacroList(charId);

	return 0;
}
its part of an old project i was working on with some friends that kinda died as the lead coder went MIA >.> 100% C++, no ASM cos i hate it, pInfoTable struct contains main info needed about a char, stored by charid for easy lookup if anyone was wondering :P hope it helps someone ^.^
testdude is offline  
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:59.