Пример #1
0
void GameSendEachUserChoice(user_node *u)
{
   val_type name_val,num_val;
   resource_node *r;
   
   AddIntToPacket(u->object_id);

   name_val.int_val = SendTopLevelBlakodMessage(u->object_id,USER_NAME_MSG,0,NULL);
   if (name_val.v.tag != TAG_RESOURCE)
   {
      eprintf("GameSendEachUserChoice object %i has non-resource name %i,%i\n",
	      u->object_id,name_val.v.tag,name_val.v.data);
      AddStringToPacket(0,"");
   }
   else
   {
      r = GetResourceByID(name_val.v.data);
      if (r == NULL)
      {
	 bprintf("GameSendEachUserChoice can't find resource %i as a resource/string\n",
		 name_val.v.data);
	    return;
      }
      AddStringToPacket(strlen(r->resource_val),r->resource_val);
   }

   num_val.int_val = SendTopLevelBlakodMessage(u->object_id,IS_FIRST_TIME_MSG,0,NULL);
   if (num_val.v.data != 0)
      AddByteToPacket(1);   /* char has been in game before */
   else
      AddByteToPacket(0);   /* char has NOT been in game before */
      
}
Пример #2
0
void GameStartUser(session_node *s,user_node *u)
{
   parm_node p;
   val_type session_id_const;

   s->game->object_id = u->object_id;

   session_id_const.v.tag = TAG_SESSION;
   session_id_const.v.data = s->session_id;

   p.type = CONSTANT;
   p.value = session_id_const.int_val;
   p.name_id = SESSION_ID_PARM;
   SendTopLevelBlakodMessage(s->game->object_id,USER_ENTER_GAME_MSG,1,&p);

   // Log of characters, accounts, ips
   val_type name_val;
   resource_node *r;
   name_val.int_val = SendTopLevelBlakodMessage(s->game->object_id,USER_NAME_MSG,0,NULL);
   r = GetResourceByID(name_val.v.data);

   if (r && r->resource_val)
     MySQLRecordPlayerLogin(s->account->name,r->resource_val,s->conn.name);

   SetSessionTimer(s,ConfigInt(CREDIT_DRAIN_TIME));
}
Пример #3
0
void MySQLRecordPlayerLogin(session_node *s)
{
	MySQLCheckConnection();
	if (!connected | !enabled)
		return;

	//Log of characters, accounts, ips
	val_type name_val;
    resource_node *r;
	char buf[1000];
	
    name_val.int_val = SendTopLevelBlakodMessage(s->game->object_id,USER_NAME_MSG,0,NULL);
    r = GetResourceByID(name_val.v.data);
    //dprintf("Account %s (%d) logged in with character %s (%d) from ip %s",s->account->name,s->account->account_id,r->resource_val,s->game->object_id,s->conn.name);

	sprintf(buf,"INSERT INTO `player_logins` \
				SET player_logins_account_name = '%s', \
				player_logins_character_name = '%s', \
				player_logins_IP = '%s', \
				player_logins_time = NOW()",s->account->name,r->resource_val,s->conn.name);
	if(mysql_query(mysqlcon, buf))
	{
		dprintf("Unable to record StatPlayerLogin", mysql_error(mysqlcon));
		return;
	}
}
Пример #4
0
/* activate the 1st timer, if it is time */
void TimerActivate()
{
   int object_id,message_id;
   UINT64 now;
   val_type timer_val;
   parm_node p[1];
   
   if (numActiveTimers == 0)
      return;
   
   now = GetMilliCount();
   if (now >= timer_heap[0]->time)
   {
   /*
     if (now - timers->time > TIMER_DELAY_WARN)
       dprintf("Timer handled %i.%03is late\n",
         (now-timers->time)/1000,(now-timers->time)%1000);
   */

      object_id = timer_heap[0]->object_id;
      message_id = timer_heap[0]->message_id;
      
      timer_val.v.tag = TAG_TIMER;
      timer_val.v.data = timer_heap[0]->timer_id;
      
      p[0].type = CONSTANT;
      p[0].value = timer_val.int_val;
      p[0].name_id = TIMER_PARM;

      TimerHeapRemove(0);

      SendTopLevelBlakodMessage(object_id,message_id,1,p);
   }
}
Пример #5
0
void SendBlakodBeginSystemEvent(int type)
{
   val_type int_val;
   parm_node p[1];

   int_val.v.tag = TAG_INT;
   int_val.v.data = type;

   p[0].type = CONSTANT;
   p[0].value = int_val.int_val;
   p[0].name_id = TYPE_PARM;

   SendTopLevelBlakodMessage(GetSystemObjectID(),GARBAGE_MSG,1,p);
}
Пример #6
0
void GameSendSystemEnter(session_node *s)
{
   parm_node p;
   val_type session_id_const;

   session_id_const.v.tag = TAG_SESSION;
   session_id_const.v.data = s->session_id;
   
   p.type = CONSTANT;
   p.value = session_id_const.int_val;
   p.name_id = SESSION_ID_PARM;
   
   SendTopLevelBlakodMessage(GetSystemObjectID(),SYSTEM_ENTER_GAME_MSG,1,&p);

}
Пример #7
0
void GameStartUser(session_node *s,user_node *u)
{
   parm_node p;
   val_type session_id_const;

   s->game->object_id = u->object_id;

   session_id_const.v.tag = TAG_SESSION;
   session_id_const.v.data = s->session_id;

   p.type = CONSTANT;
   p.value = session_id_const.int_val;
   p.name_id = SESSION_ID_PARM;
   SendTopLevelBlakodMessage(s->game->object_id,USER_ENTER_GAME_MSG,1,&p);

   SetSessionTimer(s,ConfigInt(CREDIT_DRAIN_TIME));
}
Пример #8
0
void ClientHangupToBlakod(session_node *session)
{
   val_type command,parm_list;
   parm_node parms[1];

   command.v.tag = TAG_INT;
   command.v.data = BP_REQ_QUIT;

   parm_list.int_val = NIL;
   parm_list.v.data = Cons(command,parm_list);
   parm_list.v.tag = TAG_LIST;

   parms[0].type = CONSTANT;
   parms[0].value = parm_list.int_val;
   parms[0].name_id = CLIENT_PARM;

   SendTopLevelBlakodMessage(session->game->object_id,RECEIVE_CLIENT_MSG,1,parms);
}
Пример #9
0
void GameWarnLowCredits(session_node *s)
{
   val_type str_val;
   parm_node blak_parm[1];
   char text[100];

   sprintf(text,"You have only %i credit%s remaining",s->account->credits/100,
	   (s->account->credits/100 == 1) ? "" : "s");

   SetTempString(text,strlen(text));
   str_val.v.tag = TAG_TEMP_STRING;
   str_val.v.data = 0;		/* the data field doesn't matter for TAG_TEMP_STRING */

   blak_parm[0].type = CONSTANT;
   blak_parm[0].value = str_val.int_val;
   blak_parm[0].name_id = STRING_PARM;   

   SendTopLevelBlakodMessage(s->game->object_id,SYSTEM_STRING_MSG,1,blak_parm);
}
Пример #10
0
int CreateObject(int class_id,int num_parms,parm_node parms[])
{
   int new_object_id;
   class_node *c;

   new_object_id = AllocateObject(class_id);

   if (new_object_id == INVALID_OBJECT)
      return INVALID_OBJECT;
   
   /* set self = prop 0 */
   objects[new_object_id].p[0].id = 0; 
   objects[new_object_id].p[0].val.v.tag = TAG_OBJECT; 
   objects[new_object_id].p[0].val.v.data = new_object_id;

   c = GetClassByID(class_id);
   if (c == NULL) /* can't ever be, because AllocateObject checks */
   {
      eprintf("CreateObject can't find class id %i\n",class_id);
      return INVALID_OBJECT;
   }

   SetObjectProperties(new_object_id,c);

   /* might not be top level message, since can be called from blakod.  If it
      really IS a top level message, then it better not post anything, since
      post messages won't be handled */
   if (IsInterpreting())
      SendBlakodMessage(new_object_id,CONSTRUCTOR_MSG,num_parms,parms);
   else
      SendTopLevelBlakodMessage(new_object_id,CONSTRUCTOR_MSG,num_parms,parms);

   if (ConfigBool(DEBUG_UNINITIALIZED))
   {
      int i;
      for (i = 0; i < (1+c->num_properties); i++)
	 if (objects[new_object_id].p[i].val.v.tag == TAG_INVALID)
	    eprintf("Uninitialized properties after constructor, class %s\n",
	       c->class_name);
   }

   return new_object_id;
}
Пример #11
0
void SendStringMailToObject(int string_id,int object_id)
{
#ifdef SMTP_TEST
	return;
#else
	
	val_type perm_string_const,ret_val;
	parm_node p[1];
	
	perm_string_const.v.tag = TAG_STRING;
	perm_string_const.v.data = string_id;
	
	p[0].type = CONSTANT;
	p[0].value = perm_string_const.int_val;
	p[0].name_id = PERM_STRING_PARM;
	
	ret_val.int_val = SendTopLevelBlakodMessage(object_id,RECEIVE_INTERNET_MAIL_MSG,1,p);
	
#endif
}
Пример #12
0
user_node * GetUserByName(char *username)
{
   val_type temp_str_val,ret_val;
   parm_node p[1];

   SetTempString(username,strlen(username));

   temp_str_val.v.tag = TAG_TEMP_STRING;
   temp_str_val.v.data = 0;

   p[0].type = CONSTANT;
   p[0].value = temp_str_val.int_val;
   p[0].name_id = STRING_PARM;

   ret_val.int_val = SendTopLevelBlakodMessage(GetSystemObjectID(),
					       FIND_USER_BY_STRING_MSG,1,p);
   if (ret_val.v.tag != TAG_OBJECT)
      return NULL;

   return GetUserByObjectID(ret_val.v.data);
}
Пример #13
0
/* activate the 1st timer, if it is time */
void TimerActivate()
{
   timer_node *temp;
   int object_id,message_id;
   UINT64 now;
   val_type timer_val;
   parm_node p[1];
   
   if (timers == NULL)
      return;
   
   now = GetMilliCount();
   if (now > timers->time)
   {
	/*
     if (now - timers->time > TIMER_DELAY_WARN)
       dprintf("Timer handled %i.%03is late\n",
	       (now-timers->time)/1000,(now-timers->time)%1000);
	*/

      object_id = timers->object_id;
      message_id = timers->message_id;
      
      timer_val.v.tag = TAG_TIMER;
      timer_val.v.data = timers->timer_id;
      
      p[0].type = CONSTANT;
      p[0].value = timer_val.int_val;
      p[0].name_id = TIMER_PARM;
      
      temp = timers;
      timers = timers->next;
      
      /* put deleted timer on deleted_timer list */
      StoreDeletedTimer(temp);
      
      SendTopLevelBlakodMessage(object_id,message_id,1,p);
   }
}
Пример #14
0
/* GetInternetMailObject
We return a valtype, the tag and data. */
int GetInternetMailObject(char *s)
{
#ifdef SMTP_TEST
	return NIL;
#else
	val_type temp_string_const,object_val;
	parm_node p[1];
	
	SetTempString(s,strlen(s));
	
	temp_string_const.v.tag = TAG_TEMP_STRING;
	temp_string_const.v.data = 0;
	
	p[0].type = CONSTANT;
	p[0].value = temp_string_const.int_val;
	p[0].name_id = NAME_PARM;
	
	object_val.int_val = SendTopLevelBlakodMessage(GetSystemObjectID(),
						  FIND_USER_BY_INTERNET_NAME_MSG,1,p);
	
	return object_val.int_val;
#endif   
	
}
Пример #15
0
void MainServer()
{
	InitInterfaceLocks(); 
	
	InitInterface(); /* starts a thread with the window */

   WrapInit();
	
	InitMemory(); /* memory needs channels in general, but need to start before config,
	so just be careful. */
	
	InitConfig();
	LoadConfig();		/* must be nearly first since channels use it */
	
	InitDebug();
	
	InitChannelBuffer();
	
	OpenDefaultChannels();
	
	lprintf("Starting %s\n",BlakServLongVersionString());
	
	InitClass();
	InitMessage();
	InitObject();
	InitList();
	InitTimer();
	InitSession();
	InitResource();
	InitRoomData();
	InitString();
	InitUser();
	InitAccount();
	InitNameID();
	InitDLlist();   
	InitSysTimer();
	InitMotd();
	InitLoadBof();
	InitTime();
	InitGameLock();
	InitBkodInterpret();
	InitBufferPool();
	InitTable();
	AddBuiltInDLlist();
	
	LoadMotd();
	LoadBof();
	LoadRsc();
	LoadKodbase();
	
	LoadAdminConstants();
	
	PauseTimers();
	
	if (LoadAll() == True)
	{
	/* this loaded_game_msg tells it to disconnect all blakod info about sessions,
		* that were logged on when we saved */
		
		SendTopLevelBlakodMessage(GetSystemObjectID(),LOADED_GAME_MSG,0,NULL);
		DoneLoadAccounts();
	}
	
	/* these must be after LoadAll and ClearList */
	InitCommCli(); 
	InitParseClient(); 
	InitProfiling();
	InitAsyncConnections();
	
	UpdateSecurityRedbook();
	
	UnpauseTimers();

	

	ServiceTimers();
	/* returns if server termiated */
	
	MainExitServer();
   WrapShutdown();
}