View Single Post
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-16-2014 , 11:28   Re: New API and Syntax
Reply With Quote #257

Found a bug in the new API syntax while working on mapchooser.sp.

Here's a typedef from menus.inc:

Code:
/**
 * Callback for when a vote has ended and results are available.
 *
 * @param menu				The menu being voted on.
 * @param num_votes			Number of votes tallied in total.
 * @param num_clients		Number of clients who could vote.
 * @param client_info		Array of clients.  Use VOTEINFO_CLIENT_ defines.
 * @param num_items			Number of unique items that were selected.
 * @param item_info			Array of items, sorted by count.  Use VOTEINFO_ITEM
 *							defines.
 */
typedef VoteHandler = function void (
  Menu menu,
  int num_votes, 
  int num_clients,
  const int client_info[][2], 
  int num_items,
  const int item_info[][2]
);
You can't actually have a function with this signature in the new syntax:

Code:
public void Handler_MapVoteFinished(Menu menu,
						   int num_votes, 
						   int num_clients,
						   const int client_info[][2], 
						   int num_items,
						   const int item_info[][2])
spits out error 159: brackets after variable name indicate a fixed-size array, but size could not be determined - either specify sizes, an array initializer, or use dynamic syntax (such as 'char[] x')

Code:
public void Handler_MapVoteFinished(Menu menu,
						   int num_votes, 
						   int num_clients,
						   const int[][2] client_info, 
						   int num_items,
						   const int[][2] item_info)
spits out error 140: new-style array types cannot specify dimension sizes as part of their type

Code:
public void Handler_MapVoteFinished(Menu menu,
						   int num_votes, 
						   int num_clients,
						   const int client_info[][], 
						   int num_items,
						   const int item_info[][])
tosses both error 100: function prototypes do not match and error 159: brackets after variable name indicate a fixed-size array, but size could not be determined - either specify sizes, an array initializer, or use dynamic syntax (such as 'char[] x')

and

Code:
public void Handler_MapVoteFinished(Menu menu,
						   int num_votes, 
						   int num_clients,
						   const int[][] client_info, 
						   int num_items,
						   const int[][] item_info)
spit out error 100: function prototypes do not match

To be honest, I'm not sure how you can fix this without breaking plugins... short of updating the compiler.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 12-16-2014 at 14:19.
Powerlord is offline