Example #1
0
static void
dbg_add_stackframes(proxy_msg *m, List *lst)
{
	stackframe *	s;

	proxy_msg_add_int(m, SizeOfList(lst));

	for (SetList(lst); (s = (stackframe *)GetListElement(lst)) != NULL; ) {
		dbg_add_stackframe(m, s);
	}
}
Example #2
0
static void
dbg_add_memories(proxy_msg *m, List *lst)
{
	memory *	mem;

	proxy_msg_add_int(m, SizeOfList(lst));

	for (SetList(lst); (mem = (memory *)GetListElement(lst)) != NULL; ) {
		dbg_add_memory(m, mem);
	}
}
Example #3
0
static void
dbg_add_strings(proxy_msg *m, List *lst)
{
	char *	s;

	proxy_msg_add_int(m, SizeOfList(lst));

	for (SetList(lst); (s = (char *)GetListElement(lst)) != NULL; ) {
		proxy_msg_add_string(m, s);
	}
}
Example #4
0
int Find_vList(HeadList p, Item *item){
	RadomNode *tmp = p;
	int count = 1;
	tmp = tmp->next;
	while(tmp != NULL && *item != tmp->data){
		count++;
		tmp = tmp->next;
	}
	if(count>SizeOfList(p)-1) return -1;
	return count;
}
Example #5
0
static void
dbg_add_signals(proxy_msg *m, List *lst)
{
	signal_info *	s;

	proxy_msg_add_int(m, SizeOfList(lst));

	for (SetList(lst); (s = (signal_info *)GetListElement(lst)) != NULL; ) {
		dbg_add_signalinfo(m, s);
	}
}
Example #6
0
I_ID *check_free( ID_HANDLER *handler )
{
   ITERATOR Iter;
   I_ID *id;

   if( SizeOfList( handler->free_ids ) <= 0 )
      return NULL;

   AttachIterator( &Iter, handler->free_ids );
   id = NextInList( &Iter );
   DetachFromList( id, handler->free_ids );
   DetachIterator( &Iter );
   return id;
}
Example #7
0
int PrintList(HeadList p){

	int i;
	RadomNode *r = p;
	int value = SizeOfList(p);
//	printf("value = %d\n",value);
	r = r->next;//不打印第一个头结点。
	for(i=1; i<value; i++){//这里的i=1注意下,因为链表头结点的值为一个任意值,所以在计算链表大小的时候也把头结点算上了
		printf("%d  ",r->data);
		r = r->next;
	}
	printf("\n");

	return 1;
}
Example #8
0
inline int socket_addState( lua_State *L )
{
   D_SOCKET *socket;
   SOCKET_STATE *state;

   DAVLUACM_SOCKET_NIL( socket, L );
   if( ( state = (SOCKET_STATE *)check_meta( L, 2, "State.meta" ) ) == NULL )
   {
      bug( "%s: cannot add non-State.meta to socket states.", __FUNCTION__ );
      lua_pushnil( L );
      return 1;
   }
   AttachToList( socket->states );
   lua_pushnumber( L, SizeOfList( socket->states ) );
   return 1;
}
Example #9
0
int InsertList(HeadList *p,int i, Item item){

	RadomNode *R = (RadomNode*)malloc(sizeof(RadomNode));
	RadomNode *tmp = *p;
	int count;
	for(count=0; count < SizeOfList(tmp); count ++){
		tmp = tmp->next;
		if(count == i-1){
			R->next = tmp->next;
			tmp->next = R;
			R->data = item;
		}
	}
	return 1;

}
Example #10
0
bool event_instance_lua_callback( EVENT_DATA *event )
{
   ENTITY_INSTANCE *instance = (ENTITY_INSTANCE *)event->owner;
   ENTITY_INSTANCE *arg_entity;
   void *content;
   ITERATOR Iter;
   int ret, counter = 0;

   prep_stack( get_frame_script_path( instance->framework ), event->argument );
   if( SizeOfList( event->lua_args ) > 0 )
   {
      AttachIterator( &Iter, event->lua_args );
      while( ( content = NextInList( &Iter ) ) != NULL )
      {
         switch( tolower( event->lua_cypher[counter++] ) )
         {
            case 's':
               lua_pushstring( lua_handle, (const char *)content );
               break;
            case 'n':
               lua_pushnumber( lua_handle, *((int *)content) );
               break;
            case 'i':
               if( ( arg_entity = get_active_instance_by_id( *((int *)content ) ) ) == NULL )
               {
                  bug( "%s: instance with ID:%d is no longer active.", __FUNCTION__, *((int *)content ) );
                  lua_pushnil( lua_handle );
                  break;
               }
               push_instance( arg_entity, lua_handle );
               break;
         }
      }
      DetachIterator( &Iter );
   }
   if( ( ret = lua_pcall( lua_handle, strlen( event->lua_cypher ), LUA_MULTRET, 0 ) ) )
      bug( "%s: ret %d: path: %s\r\n - error message: %s.", __FUNCTION__, ret, get_frame_script_path( instance->framework ), lua_tostring( lua_handle, -1 ) );

   return FALSE;
}
Example #11
0
inline int socket_getState( lua_State *L )
{
   D_SOCKET *socket;
   SOCKET_STATE *state;
   ITERATOR Iter;
   int index;

   DAVLUACM_SOCKET_NIL( socket, L );
   if( lua_gettop( L ) != 2 )
   {
      bug( "%s: bad number of arguments passed.", __FUNCTION__ );
      lua_pushnil( L );
      return 1;
   }
   if( lua_type( L, 2 ) != LUA_TNUMBER )
   {
      bug( "%s: bad argument passed.", __FUNCTION__ );
      lua_pushnil( L );
      return 1;
   }

   index = lua_tonumber( L, 2 );
   if( index < 1 || index > SizeOfList( socket->states ) )
   {
      bug( "%s: index passed, out of range." , __FUNCTION__ );
      lua_pushnil( L );
      return 1;
   }
   if( ( state = (SOCKET_STATE *)GetFromListIndex( socket->states, index ) ) == NULL )
   {
      lua_pushnil( L );
      return 1;
   }
   lua_pushobj( L, state, SOCKET_STATE );
   return 1;
}
Example #12
0
void reset_area( D_AREA *area )
{
   ITERATOR it,rIt; // it = room iterator, rIt = reset iterator
   D_OBJ *o;
   D_RESET *reset;
   D_MOBILE *m;
   D_ROOM *room;
   
   AttachIterator( &it, area->rooms );
   while( ( room = (D_ROOM*)NextInList( &it ) ) != NULL )
   {
      AttachIterator( &rIt, room->resets );
      while( ( reset = (D_RESET*)NextInList(&rIt) ) != NULL )
      {
         switch( reset->type )
         {
            default:
            {
               bug( "Invalid reset type %c.", reset->type );
               break;
            }
            case 'o':
            case 'O':
            {
                //if the reset has already fired once we need to see if the object
                //is still there, if its not, make a new one.
               if( reset->ptr )
               {
                  //if object is still there skip this reset
                  if( IsInList( reset->ptr, room->objects ) ) 
                     continue;
               }
               if( ( o = clone_obj( fobv( reset->vnum ) ) ) == NULL )
               {
                  bug( "Reset calls for object vnum %i which does not exist.", reset->vnum );
                  continue;
               }
               AttachToList( o, room->objects );
               //does the reset reference any subresets (contained objects)?
               if( reset->nest && SizeOfList( reset->nest ) > 0 )
               {
               }
               
               o->reset = reset;
               reset->ptr = o;
               break;
            }
            case 'm':
            case 'M':
            {
               if( reset->ptr )
               {
                  if( IsInList( reset->ptr, npc_list ) )
                     continue;
               }
               if( ( m = clone_npc( fmbv( reset->vnum ) ) ) == NULL )
               {
                  bug( "Reset calls for NPC vnum %i which does not exist.", reset->vnum );
                  continue;
               }
               AttachToList( m, room->mobiles );
               m->npc_data->reset = reset;
               reset->ptr = m;
               break;
            }
         }
      }
      DetachIterator( &rIt );
   }
   DetachIterator( &it );
   return;
}