Re: [hlcoders] string to #define

2002-05-29 Thread Mugsy _


Yes! I had given up on this idea, but I guess I didn't imagine it after all
:) This is exactly what I was thinking of.

Thanks for finding this

Mugsy

From: Pat Magnan [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [hlcoders] string to #define
Date: Tue, 28 May 2002 22:21:35 -0500

Hey Mugsy:

Did you ever figure this out? I was browsing the comp.lang.c newsgroup FAQ
(ok, somebody needs a life :P), and found this:
Question 11.17
I'm trying to use the ANSI ``stringizing'' preprocessing operator `#' to
insert the value of a symbolic constant into a message, but it keeps
stringizing the macro's name rather than its value.

-

You can use something like the following two-step procedure to force a
macro
to be expanded as well as stringized:

   #define Str(x) #x
   #define Xstr(x) Str(x)
   #define OP plus
   char *opname = Xstr(OP);

This code sets opname to plus rather than OP.

An equivalent circumlocution is necessary with the token-pasting operator
##
when the values (rather than the names) of two macros are to be
concatenated.

References: ANSI Sec. 3.8.3.2, Sec. 3.8.3.5 example
ISO Sec. 6.8.3.2, Sec. 6.8.3.5


http://www.eskimo.com/~scs/C-faq/q11.17.html

I think you were trying to get the preprocessor to expand and then
'stringize' your #define'd constant, passing it's value as the arg to your
func, which is what that code appears to do.



Pat 'sluggo' Magnan
Tour of Duty Mod
http://www.tourofdutymod.com




- Original Message -
From: Mugsy _ [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, May 07, 2002 2:29 AM
Subject: Re: [hlcoders] string to #define


 The pre-processors scan through source files replacing the
  define
with
 the value.

 I'm not 100% sure, but about 95% that it looks in strings
as
  well,
so

 someFuncThatTakesAString(WEAPON_GARAND);

 will get changed to

 someFuncThatTakesAString(2); file://constant string 2\0

 before its compiled.


___
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders


_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

___
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders




Re: [hlcoders] string to #define

2002-05-07 Thread Mugsy _


That still does a O(n) search with string compares.

The one I'm dreaming of is different.


From: Josh Coyne [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [hlcoders] string to #define
Date: Tue, 7 May 2002 01:24:37 -0400

okay then

int iGetIdForString(char *cmp_string)
{
 weaponchar_id_t *comp_block;
 int num = 0;

 while((comp_block = WeaponCodes[num++]) != NULL)
 {
 if(strcmp(cmp_string,comp_block-cStringId) == 0)
 return comp_block-iId;
 }
 return -1;
}

that should do it...

- Original Message -
From: Mugsy _ [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, May 06, 2002 11:54 PM
Subject: Re: [hlcoders] string to #define


  I need to go the other way, from string to int.
 
 
  From: Josh Coyne [EMAIL PROTECTED]
  Reply-To: [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Subject: Re: [hlcoders] string to #define
  Date: Mon, 6 May 2002 23:52:26 -0400
  
  well with the string array you could just do like
  
  char *cGetStringForId(int iId)
  {
   weaponchar_id_t *comp_block;
   int num = 0;
  
   while((comp_block = WeaponCodes[num++]) != NULL)
   {
   if(comp_block-iId == iId)
   return comp_block-cStringId;
   }
   return NULL;// or return  or whatever u want
  }
  
  should give you an idea of what i mean by a list array
  
  - Original Message -
  From: Mugsy _ [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Monday, May 06, 2002 11:40 PM
  Subject: Re: [hlcoders] string to #define
  
  
   
Yeah I thought about that but I think it ends up with a lot of
string
compares. The particular method I am thinking of ( I might be
  remembering
some magical C++ dream I had ) acutally involved converting a string
  into
  a
variable name directly.
   
But I'm most likely on crack.
   
   
   
From: Josh Coyne [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [hlcoders] string to #define
Date: Mon, 6 May 2002 23:25:33 -0400

hmm

a possible idea could be a string table maybe

an array of string/code structs, like

typedef struct
{
 char cStringId[256];
 int iId;
}weaponchar_id_t;

then you could perhaps have like

weaponchar_id_t WeaponCodes[] = {
 { WEAPON_GARAND,2 },
 { WEAPON_1911, 1},
 NULL,
 // etc
};

then have a support function or two to grab the string/int and
compare
  in
this array
this could be more work, who knows, but here it looks a bit easier
to
  just
reference similar items in an array

- Original Message -
From: Dynerman David M [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, May 06, 2002 11:10 PM
Subject: RE: [hlcoders] string to #define


  Well they say when you're not sure try..so I did and Leon's
right
  (at
  least with VC++)
 
  I'm not sure where I saw/read that it would scan quotes, but the
  define
  didn't work for me (it would just print out WEAPON_GARAND
instead
of
  2)
 
  Looks like we're stuck defining string literals or numbers, but
not
  mixing  matching.
 
  david
 
  -Original Message-
  From: Leon Hartwig [mailto:[EMAIL PROTECTED]]
  Sent: Monday, May 06, 2002 9:50 PM
  To: '[EMAIL PROTECTED]'
  Subject: RE: [hlcoders] string to #define
 
  I'm sure it depends on which preprocessor is being used, but I
doubt
  most
  modern ones do this.
 
 
   -Original Message-
   From: Dynerman David M
[mailto:[EMAIL PROTECTED]]
   Sent: Monday, May 06, 2002 7:35 PM
   To: [EMAIL PROTECTED]
   Subject: RE: [hlcoders] string to #define
  
  
   The pre-processors scan through source files replacing the
define
  with
   the value.
  
   I'm not 100% sure, but about 95% that it looks in strings as
well,
  so
  
   someFuncThatTakesAString(WEAPON_GARAND);
  
   will get changed to
  
   someFuncThatTakesAString(2); //constant string 2\0
  
   before its compiled.
  ___
  To unsubscribe, edit your list preferences, or view the list
  archives,
  please visit:
  http://list.valvesoftware.com/mailman/listinfo/hlcoders
 
  ___
  To unsubscribe, edit your list preferences, or view the list
  archives,
please visit:
  http://list.valvesoftware.com/mailman/listinfo/hlcoders
 

___
To unsubscribe, edit your list preferences, or view the list
archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders
   
   
_
Get your FREE download of MSN Explorer

[hlcoders] string to #define

2002-05-06 Thread Mugsy _

This is more general C++, but its for a HL mod so..

If I have a string, is there a way to convert it to integer with a
previously enumerated value?

eg,
#define WEAPON_GARAND 2

then if I read in a string, and it happens to be WEAPON_GARAND can I know
that that symbol is defined as 2? Obviously without doing an enormous
if/else strcmp block..

Mugsy
Day of Defeat mod

_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

___
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders




Re: [hlcoders] string to #define

2002-05-06 Thread Mugsy _


It doesnt have to be a define, it can be an enumerated variable. ( since
#define names would probably be tossed in a compiled version )

enum
{
   WEAPON_GARAND = 2
};

From: Mugsy _ [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [hlcoders] string to #define
Date: Mon, 06 May 2002 19:17:02 -0700

This is more general C++, but its for a HL mod so..

If I have a string, is there a way to convert it to integer with a
previously enumerated value?

eg,
#define WEAPON_GARAND 2

then if I read in a string, and it happens to be WEAPON_GARAND can I know
that that symbol is defined as 2? Obviously without doing an enormous
if/else strcmp block..

Mugsy
Day of Defeat mod

_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

___
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders



_
Chat with friends online, try MSN Messenger: http://messenger.msn.com

___
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders




Re: [hlcoders] string to #define

2002-05-06 Thread Mugsy _


Yeah I thought about that but I think it ends up with a lot of string
compares. The particular method I am thinking of ( I might be remembering
some magical C++ dream I had ) acutally involved converting a string into a
variable name directly.

But I'm most likely on crack.



From: Josh Coyne [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [hlcoders] string to #define
Date: Mon, 6 May 2002 23:25:33 -0400

hmm

a possible idea could be a string table maybe

an array of string/code structs, like

typedef struct
{
 char cStringId[256];
 int iId;
}weaponchar_id_t;

then you could perhaps have like

weaponchar_id_t WeaponCodes[] = {
 { WEAPON_GARAND,2 },
 { WEAPON_1911, 1},
 NULL,
 // etc
};

then have a support function or two to grab the string/int and compare in
this array
this could be more work, who knows, but here it looks a bit easier to just
reference similar items in an array

- Original Message -
From: Dynerman David M [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, May 06, 2002 11:10 PM
Subject: RE: [hlcoders] string to #define


  Well they say when you're not sure try..so I did and Leon's right (at
  least with VC++)
 
  I'm not sure where I saw/read that it would scan quotes, but the define
  didn't work for me (it would just print out WEAPON_GARAND instead of 2)
 
  Looks like we're stuck defining string literals or numbers, but not
  mixing  matching.
 
  david
 
  -Original Message-
  From: Leon Hartwig [mailto:[EMAIL PROTECTED]]
  Sent: Monday, May 06, 2002 9:50 PM
  To: '[EMAIL PROTECTED]'
  Subject: RE: [hlcoders] string to #define
 
  I'm sure it depends on which preprocessor is being used, but I doubt
  most
  modern ones do this.
 
 
   -Original Message-
   From: Dynerman David M [mailto:[EMAIL PROTECTED]]
   Sent: Monday, May 06, 2002 7:35 PM
   To: [EMAIL PROTECTED]
   Subject: RE: [hlcoders] string to #define
  
  
   The pre-processors scan through source files replacing the define with
   the value.
  
   I'm not 100% sure, but about 95% that it looks in strings as well, so
  
   someFuncThatTakesAString(WEAPON_GARAND);
  
   will get changed to
  
   someFuncThatTakesAString(2); //constant string 2\0
  
   before its compiled.
  ___
  To unsubscribe, edit your list preferences, or view the list archives,
  please visit:
  http://list.valvesoftware.com/mailman/listinfo/hlcoders
 
  ___
  To unsubscribe, edit your list preferences, or view the list archives,
please visit:
  http://list.valvesoftware.com/mailman/listinfo/hlcoders
 

___
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders


_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

___
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders




Re: [hlcoders] string to #define

2002-05-06 Thread Mugsy _

I need to go the other way, from string to int.


From: Josh Coyne [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [hlcoders] string to #define
Date: Mon, 6 May 2002 23:52:26 -0400

well with the string array you could just do like

char *cGetStringForId(int iId)
{
 weaponchar_id_t *comp_block;
 int num = 0;

 while((comp_block = WeaponCodes[num++]) != NULL)
 {
 if(comp_block-iId == iId)
 return comp_block-cStringId;
 }
 return NULL;// or return  or whatever u want
}

should give you an idea of what i mean by a list array

- Original Message -
From: Mugsy _ [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, May 06, 2002 11:40 PM
Subject: Re: [hlcoders] string to #define


 
  Yeah I thought about that but I think it ends up with a lot of string
  compares. The particular method I am thinking of ( I might be
remembering
  some magical C++ dream I had ) acutally involved converting a string
into
a
  variable name directly.
 
  But I'm most likely on crack.
 
 
 
  From: Josh Coyne [EMAIL PROTECTED]
  Reply-To: [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Subject: Re: [hlcoders] string to #define
  Date: Mon, 6 May 2002 23:25:33 -0400
  
  hmm
  
  a possible idea could be a string table maybe
  
  an array of string/code structs, like
  
  typedef struct
  {
   char cStringId[256];
   int iId;
  }weaponchar_id_t;
  
  then you could perhaps have like
  
  weaponchar_id_t WeaponCodes[] = {
   { WEAPON_GARAND,2 },
   { WEAPON_1911, 1},
   NULL,
   // etc
  };
  
  then have a support function or two to grab the string/int and compare
in
  this array
  this could be more work, who knows, but here it looks a bit easier to
just
  reference similar items in an array
  
  - Original Message -
  From: Dynerman David M [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Monday, May 06, 2002 11:10 PM
  Subject: RE: [hlcoders] string to #define
  
  
Well they say when you're not sure try..so I did and Leon's right
(at
least with VC++)
   
I'm not sure where I saw/read that it would scan quotes, but the
define
didn't work for me (it would just print out WEAPON_GARAND instead of
2)
   
Looks like we're stuck defining string literals or numbers, but not
mixing  matching.
   
david
   
-Original Message-
From: Leon Hartwig [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 06, 2002 9:50 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [hlcoders] string to #define
   
I'm sure it depends on which preprocessor is being used, but I doubt
most
modern ones do this.
   
   
 -Original Message-
 From: Dynerman David M [mailto:[EMAIL PROTECTED]]
 Sent: Monday, May 06, 2002 7:35 PM
 To: [EMAIL PROTECTED]
 Subject: RE: [hlcoders] string to #define


 The pre-processors scan through source files replacing the define
with
 the value.

 I'm not 100% sure, but about 95% that it looks in strings as well,
so

 someFuncThatTakesAString(WEAPON_GARAND);

 will get changed to

 someFuncThatTakesAString(2); //constant string 2\0

 before its compiled.
___
To unsubscribe, edit your list preferences, or view the list
archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders
   
___
To unsubscribe, edit your list preferences, or view the list
archives,
  please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders
   
  
  ___
  To unsubscribe, edit your list preferences, or view the list archives,
  please visit:
  http://list.valvesoftware.com/mailman/listinfo/hlcoders
 
 
  _
  Get your FREE download of MSN Explorer at
http://explorer.msn.com/intl.asp.
 
  ___
  To unsubscribe, edit your list preferences, or view the list archives,
please visit:
  http://list.valvesoftware.com/mailman/listinfo/hlcoders
 

___
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders



_
Chat with friends online, try MSN Messenger: http://messenger.msn.com

___
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders




[hlcoders] HLTV 1109 quick fix

2002-04-30 Thread Mugsy _

Hey all,

Had a chat with Martin Otten, and he sent me some info to get HLTV working
again in 1109, until they can release another SDK.

Check it out at http://www.captured.com/savage/hltv_1109_fix.html

I make all the usual disclaimers associated with tutorials. Let me know if
there are any big errors and I'll fix em.

Matt Mugsy Boone
Day of Defeat mod
www.dayofdefeatmod.com

_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

___
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders




Re: [hlcoders] Network metering source code

2002-04-21 Thread Mugsy _


Hey Charlie,

Are your players overflowing all the time? at random times or at one
specific point in the game? Unless youre doing some really bad loops with
messages being sent inside them, or youre sending big hunks of data, you
shouldnt have to change the networking.. Especially with all the client
stuff I know you're doing.

Make sure you've fixed the bug with the voice manager that causes overflows.
You should comment out the calls to UpdateMasks() in
CVoiceGameMgr::ClientCommand.

Also, I made a metamod dll that counts user messages. Its very basic, but if
you want it gimme a shout.

Mugsy

From: Charlie Cleveland [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [hlcoders] Network metering source code
Date: Fri, 19 Apr 2002 10:54:38 -0400


   Hello everyone,

   In working on Natural Selection, I've encountered problems with players
overflowing.  Yahn tells me that this is because NS is sending too much
reliable data to a player at once, causing the player to be
disconnected.  He also mentions that due to the vagaries of different mods
and network data usage, the best solution is probably meter the network
data, ie, network messages should be queued up, and only sent out a fixed
rate, to prevent overflowage.

   I wrote a general purpose solution and it occurs to me that that other
mods could benefit from it.

   http://www.natural-selection.org/iB_html/uploads/cgc-NetworkMeter.zip

   The main code is NetworkMeter.* and the hooks to the HL source are
explained in NetworkMeterMisc.cpp.  I'm still experimenting with values,
but right now I have the data rate set to 1000 bytes per second, and we're
seeing way less overflows, though we may still be seeing some.  If this
value is set very low, you'll see delays when joining teams, receiving your
weapons list, etc. (but everything should still work).

   Feel free to use this code however you like.  May your players never
overflow again!

-Charlie
Charlie Cleveland
Game programmer and designer
http://www.natural-selection.org
[EMAIL PROTECTED]

___
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders



_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

___
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders




[hlcoders] strange install error

2002-03-22 Thread Mugsy _

Just running through a special version of a patch i'm making, and i'm
getting this error when I try to connect to a game through the multiplayer
browser:

You cannot connect to a server running custom game dod until you install the
custom game

Now, I can join servers from the command line no prob, and the mod is
obviously loaded, because all the interface is the dod interface.

Any ideas?

Mugsy

_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

___
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders




Re: [hlcoders] HLTV overviews

2002-03-14 Thread Mugsy _


Its included in the SDk 2.2 zip file.


From: Daniel Koppes [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [hlcoders] HLTV overviews
Date: Fri, 15 Mar 2002 16:00:23 +1300 (NZDT)

  --- David Flor [EMAIL PROTECTED] wrote:  For
the life of me I can't find the document that
  describes how to
  create the 2D overview images for HLTV. Somebody out
  there have it
  handy?
 
  Thanks!
 
As i recall... you put NOCLIP on, fly _above_ the
level look down, and set a special CVAR that
changes how HL renders the level... so there is no
perspective... then just take a screenshot. You'll
have to alter it in a paint program afterwards

Suitable vague explanation, but i can't remember the
specifics :)


___
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders



_
Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com

___
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders




Re: [hlcoders] console command

2001-12-05 Thread Mugsy _


SERVER_COMMAND(buf);


From: Cortex [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: coders [EMAIL PROTECTED]
Subject: [hlcoders] console command
Date: Wed, 5 Dec 2001 17:56:07 +0100

Hello,

What is the function ( server side ) to reproduce a
console command ? I mean this function would act like
ClientCmd client side.

Thanks ;)


Cortex
HL Albator coder  mapper
www.hlalbator.fr.st



_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

___
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders