Thread Tools
Old October 11, 2002, 17:38   #1
mapfi
Call to Power II Democracy GameCall to Power II Multiplayer
Prince
 
Local Time: 10:15
Local Date: November 1, 2010
Join Date: Jul 2002
Location: San Francisco, CA
Posts: 848
IsHumanPlayer() in Multiplayer
The question has been raised before (here: http://apolyton.net/forums/showthrea...threadid=62653)

Does the function IsHumanPlayer work properly in multiplayer games?

I did some testing tonight and here's what I found... (warning bad news!)

The one and only time the function would work in my setup was when it was a human player's turn (host or not) and the argument tested was his player number. No other player number would work when a human played and neither would it run on the AI's turns but there not even with the AI's player number as an argument.
The error returned is always "_IsHumanPlayer: Wrong number of arguments"
I can only think of some mistake in the code of the function itself which obviously renders it useless for any MP setup then...
mapfi is offline  
Old December 31, 2002, 12:16   #2
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 11:15
Local Date: November 1, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
What was the exact code mapfi and did you tested it with DebugSlic=Yes?

-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
Martin Gühmann is offline  
Old January 2, 2003, 11:22   #3
mapfi
Call to Power II Democracy GameCall to Power II Multiplayer
Prince
 
Local Time: 10:15
Local Date: November 1, 2010
Join Date: Jul 2002
Location: San Francisco, CA
Posts: 848
hm, that was a while ago already... I just wrote something for testing, like a BeginTurn handler that would give me the result of is humanplayer in a message box.
mapfi is offline  
Old January 2, 2003, 14:18   #4
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 11:15
Local Date: November 1, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
So it would be something like this (if I use the information from your first post):

Code:
HandleEvent(BeginTurn)'Test_IsHumanPlayer'post{
    if(IsHumanPlayer(1)){
         //Do something here
    }
}
This could be a little bit problematic, because players and ints are not the same thing, in the slic documentation you find this:

player.owner - An integer version of the player.

This is a hint that ints and players are not identical, but obviously we have a lot of implecit typecasts here in slic, but unfortunatly they fail sometimes. And other functions expects a integer representaion of the player as argument.

I think something like this should work:

Code:
HandleEvent(BeginTurn)'Test_IsHumanPlayer'post{
    if(IsHumanPlayer(player[0])){
         //Do something here
    }
}
Also this could work:

Code:
HandleEvent(BeginTurn)'Test_IsHumanPlayer'post{
    player[0] = 1;
    if(IsHumanPlayer(player[0])){
         //Do something here
    }
}
And this should also work:

Code:
HandleEvent(BeginTurn)'Test_IsHumanPlayer'post{
    if(IsHumanPlayer(g.player)){
         //Do something here
    }
}
In frenzy we have the problem that ints and players treated as the same thing. Most of the frenzy arguments for the IsHumanPlayer function are integers and not players.

-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
Martin Gühmann is offline  
Old January 2, 2003, 14:41   #5
mapfi
Call to Power II Democracy GameCall to Power II Multiplayer
Prince
 
Local Time: 10:15
Local Date: November 1, 2010
Join Date: Jul 2002
Location: San Francisco, CA
Posts: 848
I honestly can't remember - I would think I did something like
Code:
HandleEvent(BeginTurn) {
for (i = 1; i <= Num; i = i + 1) {
	player[0] = i;
	result[i] = IsHumanPlayer(player[0]);
	}
message(g.player, 'test');
}
but I wouldn't be able to swear on this... someone will have to try again, sorry
mapfi is offline  
Old January 2, 2003, 16:46   #6
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 11:15
Local Date: November 1, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
Well this code will work as you described. Whenever the BeginTurn event is called a message is send to the current player (that's g.player) and no other player will recieve the message. In theory the result array should contain a lot of zeros and ones, but so far I don't see what do you want to do with the result array.

A code that could test it would be something like this:
Code:
HandleEvent(BeginTurn)'Test_IsHumanPlayer'post{
     if(IsHumanPlayer(player[0])){
           Message(1, 'Test_IsHumanPlayer');
     }
     else{
           Message(1, 'Test_IsNotHumanPlayer');
     }
}
So if you are player 1 then you will receive a buch of messages, as much as human players are in the game, and you should get as much messages as AI players are in the game.

-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
Martin Gühmann is offline  
 

Bookmarks

Thread Tools

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 On

Forum Jump


All times are GMT -4. The time now is 05:15.


Design by Vjacheslav Trushkin, color scheme by ColorizeIt!.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Apolyton Civilization Site | Copyright © The Apolyton Team