newfeat: $Servername ??

A forum for feature requests/discussions and user submitted patches that improve MQ2

Moderator: MacroQuest Developers

LordGiddion
a snow griffon
a snow griffon
Posts: 352
Joined: Sat Sep 13, 2003 6:12 pm
Contact:

newfeat: $Servername ??

Post by LordGiddion » Tue Oct 21, 2003 10:25 am

Ok rather then ask for something this time I thought I try coding it.
$servername returns the name of the server your playing on.
I haven't tried it yet - at work right now.
Please let me know if I missed something.
in MacroParser.h

Code: Select all

//pmp funcs
PARMFUNC(parmServerName)

Code: Select all

PARMLIST Parms[] = {
{"servername", "parmServerName", NULL},
in macroParser.cpp

Code: Select all

DWORD parmServerName(PCHAR szVar, PCHAR szOutput, PSPAWNINFO pChar)
{
    // $servername
    strcat(szOutput,((PCHAR)EQADDR_SERVERNAME));
    return 14;
}

LordGiddion
a snow griffon
a snow griffon
Posts: 352
Joined: Sat Sep 13, 2003 6:12 pm
Contact:

Post by LordGiddion » Wed Oct 22, 2003 11:23 am

McKorr,
I understand you've worked with the servername for another peice of code, can you see if this looks right to you?

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Wed Oct 22, 2003 11:52 am

Take a look in EQLib_Mouse. The routine that determines the UI_Character_Server.ini file.

Code: Select all

	if (!EQADDR_SERVERNAME) 
		return FALSE;
	sprintf(UIFile,"%s\\UI_%s_%s.ini",gszEQPath,pCharInfo->Name,EQADDR_SERVERNAME);
I think that would make it

Code: Select all

DWORD parmServerName(PCHAR szVar, PCHAR szOutput) 
{ 
    // $servername 
    strcat(szOutput,EQADDR_SERVERNAME); 
    return 14; 
}
MQ2: Think of it as Evolution in action.

LordGiddion
a snow griffon
a snow griffon
Posts: 352
Joined: Sat Sep 13, 2003 6:12 pm
Contact:

Post by LordGiddion » Thu Oct 23, 2003 12:30 pm

Darn I missed something, Both codes CTD
So much for my first effort, can someone more knowledgable give me a hint where I messed up? I'd like to be a useful contributor - but not quite sure what I'm missing.

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Thu Oct 23, 2003 1:18 pm

I'll throw you a bone here :) Mckorr is great, but not so much of an expert at C++ as he is with other parts of the project.

So here's the deal -- printf is looking for extra parameters as void*, whereas strcat is looking for char*. In other words, it doesn't need a type cast to become void* from whatever it happens to be, to be used in printf. Luckily, EQADDR_SERVERNAME is defined as PCHAR, so your type cast ((PCHAR)EQADDR_SERVERNAME) doesn't do anything and will work the same way with or without it.

The only thing I'd be concerned with is the return 14.

Code: Select all

 *       DWORD return value: Old "i++" value. e.g. number of chars to skip   *
 *                           in original string. Size of your parameter,     *
 *                           without the "$", and minus 1. $spawn(250,type)  *
 *                           should return 14. Returning 10000 indicates an  *
 *                           error return. (Bad macro parameter)             *
 *                                                                           *
012345678901234
$spawn(250,type)
$servername

return 10 instead and your code should work as far as I know :)
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

LordGiddion
a snow griffon
a snow griffon
Posts: 352
Joined: Sat Sep 13, 2003 6:12 pm
Contact:

Post by LordGiddion » Thu Oct 23, 2003 2:14 pm

Nope return 10 still CTD

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Fri Oct 24, 2003 9:12 am

Lax, I suck at C++ :D I'm an Intelligence Analyst by trade, not a programmer. I also missed something.

Code: Select all

DWORD parmServerName(PCHAR szVar, PCHAR szOutput, [color=red]PSPAWNINFO pChar[/color]) 
{ 
    // $servername 
    strcat(szOutput,EQADDR_SERVERNAME); 
    return [color=red]10[/color]; 
}
Try that.
MQ2: Think of it as Evolution in action.