IXRefFilesNode* CWsDfuXRefEx::getFileNodeInterface(IXRefNode& XRefNode,const char* nodeType)
{
    if (strcmp("Found" ,nodeType) == 0)
        return XRefNode.getFoundFiles();
    else if (strcmp("Lost" ,nodeType) == 0)
        return XRefNode.getLostFiles();
    else if (strcmp("Orphan" ,nodeType) == 0)
        return XRefNode.getOrphanFiles();
    else
        WARNLOG("Unrecognized file node type %s",nodeType);
    return 0;
}
Exemple #2
0
short load_continue_game(void)
{
    unsigned char buf[14];
    unsigned char bonus[20];
    char cmpgn_fname[CAMPAIGN_FNAME_LEN];
    long lvnum;
    long i;

    if (!read_continue_game_part(buf,0,14))
    {
        WARNLOG("Can't read continue game file head");
        return false;
    }
    i = (char *)&game.campaign_fname[0] - (char *)&game;
    read_continue_game_part((unsigned char *)cmpgn_fname,i,CAMPAIGN_FNAME_LEN);
    cmpgn_fname[CAMPAIGN_FNAME_LEN-1] = '\0';
    if (!change_campaign(cmpgn_fname))
    {
        ERRORLOG("Unable to load campaign");
        return false;
    }
    lvnum = ((struct Game *)buf)->continue_level_number;
    if (!is_singleplayer_like_level(lvnum))
    {
      WARNLOG("Level number in continue file is incorrect");
      return false;
    }
    set_continue_level_number(lvnum);
    LbMemorySet(bonus, 0, sizeof(bonus));
    i = (char *)&game.intralvl.bonuses_found[0] - (char *)&game;
    read_continue_game_part(bonus,i,16);
    for (i=0; i < BONUS_LEVEL_STORAGE_COUNT; i++)
      game.intralvl.bonuses_found[i] = bonus[i];
    LbStringCopy(game.campaign_fname,campaign.fname,sizeof(game.campaign_fname));
    update_extra_levels_visibility();
    i = (char *)&game.intralvl_transfered_creature - (char *)&game.intralvl.bonuses_found[0];
    game.intralvl_transfered_creature.model = bonus[i];
    game.intralvl_transfered_creature.explevel = bonus[i+1];
    return true;
}
Exemple #3
0
TbBool set_pointer_graphic_spell(long group_idx, long frame)
{
  long i,x,y;
  struct TbSprite *spr;
  SYNCDBG(8,"Setting to group %d",(int)group_idx);
  if (pointer_sprites == NULL)
  {
    WARNLOG("Pointer sprites not loaded, setting to none");
    LbMouseChangeSpriteAndHotspot(NULL, 0, 0);
    return false;
  }
  if ((group_idx < 0) || (group_idx >= SPELL_POINTER_GROUPS))
  {
    WARNLOG("Group index out of range, setting pointer to none");
    LbMouseChangeSpriteAndHotspot(NULL, 0, 0);
    return false;
  }
  if (is_feature_on(Ft_BigPointer))
  {
    y = 32;
    x = 32;
    i = 8*group_idx + (frame%8);
  } else
  {
    y = 78;
    x = 26;
    i = group_idx;
  }
  spr = &pointer_sprites[40+i];
  SYNCDBG(8,"Activating pointer %d",40+i);
  if ((spr >= pointer_sprites) && (spr < end_pointer_sprites))
  {
    LbMouseChangeSpriteAndHotspot(spr, x/2, y/2);
  } else
  {
    WARNLOG("Sprite %d exceeds buffer, setting pointer to none",(int)i);
    LbMouseChangeSpriteAndHotspot(NULL, 0, 0);
  }
  return true;
}
Exemple #4
0
bool updateDaliEnv(IPropertyTree *env, bool forceGroupUpdate, const char *daliIp)
{
    Owned<IPropertyTreeIterator> dalis = env->getElements("Software/DaliServerProcess/Instance");
    if (!dalis||!dalis->first()) {
        fprintf(stderr,"Could not find DaliServerProcess\n");
        return false;
    }
    SocketEndpoint daliep;
    loop {
        const char *ps = dalis->get().queryProp("@port");
        unsigned port = ps?atoi(ps):0;
        if (!port)
            port = DALI_SERVER_PORT;
        daliep.set(dalis->get().queryProp("@netAddress"),port);
        if (daliIp && *daliIp) {
            SocketEndpoint testep;
            testep.set(daliIp,DALI_SERVER_PORT);
            if (testep.equals(daliep))
                break;
            daliep.set(NULL,0);
        }
        if (!dalis->next())
            break;
        if (!daliep.isNull()) {
            fprintf(stderr,"Ambiguous DaliServerProcess instance\n");
            return false;
        }
    }
    if (daliep.isNull()) {
        fprintf(stderr,"Could not find DaliServerProcess instance\n");
        return false;
    }
    SocketEndpointArray epa;
    epa.append(daliep);
    Owned<IGroup> group = createIGroup(epa);

    bool ret = true;
    initClientProcess(group, DCR_Util);
    StringBuffer response;
    if (querySDS().updateEnvironment(env, forceGroupUpdate, response))
    {
        StringBuffer tmp;
        PROGLOG("Environment and node groups updated in dali at %s",daliep.getUrlStr(tmp).str());
    }
    else
        ret = false;
    if (response.length())
        WARNLOG("%s", response.str());

    closedownClientProcess();
    return ret;
}
void CEclAgentExecutionServer::start()
{
    if (started)
    {
        WARNLOG("START called when already started\n");
        assert(false);
    }

    Owned<IPropertyTree> properties;
    try
    {
        DBGLOG("AgentExec: Loading properties file 'agentexec.xml'");
        properties.setown(createPTreeFromXMLFile("agentexec.xml"));
    }
    catch (IException *e) 
    {
        EXCLOG(e, "Error processing properties file\n");
        throwUnexpected();
    }

    {
        //Build logfile from component properties settings
        Owned<IComponentLogFileCreator> lf = createComponentLogFileCreator(properties, "eclagent");
        lf->setCreateAliasFile(false);
        lf->beginLogging();
        PROGLOG("Logging to %s",lf->queryLogFileSpec());
    }

    //get name of workunit job queue
    StringBuffer sb;
    properties->getProp("@name", sb.clear());
    agentName.set(sb);
    if (!agentName.length())
    {
        ERRLOG("'name' not specified in properties file\n");
        throwUnexpected();
    }
    setStatisticsComponentName(SCThthor, agentName, true);

    //get dali server(s)
    properties->getProp("@daliServers", daliServers);
    if (!daliServers.length())
    {
        ERRLOG("'daliServers' not specified in properties file\n");
        throwUnexpected();
    }

    started = true;
    Thread::start();
    Thread::join();
}
Exemple #6
0
static int open_fd(void)
{
    static int fd = -1;
	if (-1 == fd)
	  {
		fd = open("/dev/tvp5150", O_RDWR);
		if (fd < 0) 
		  {
			WARNLOG("unable to open tvp5150 control.\n");
			return -1;
		  }
	  }
	return fd;
}
Exemple #7
0
/** check OSD file type. 
 *
 * @param name
 *        file name.
 * @return
 *        OSD file type if successful, otherwise -1.
 *
 */
EM_OSD_FILE_TYPE CoolOsdFileType(const char *name)
{
	struct stat		statbuf;
	
	//FIXME: ugly, a better algorithm is needed here, what about ftp? https?.
	if ((*(name+0) == 'h' &&
		 *(name+1) == 't' &&
		 *(name+2) == 't' &&
		 *(name+3) == 'p' &&
		 *(name+4) == ':') ||
		(*(name+0) == 'f' &&
		 *(name+1) == 't' &&
		 *(name+2) == 'p' &&
		 *(name+3) == ':'))
		goto skip_local_check;

	if (stat(name, &statbuf)<0)
	{
		WARNLOG("file status error: %s", name);
		return -1;
	}
	else
	{
		if (S_ISDIR(statbuf.st_mode))//S_ISREG
		{
			return oftDIRECTORY;
		}
		else
		{
		skip_local_check:
			if (CoolIsImageFile(name))
				return oftIMAGE;
			else if (CoolIsAudioFile(name))
				return oftAUDIO;
			else if (CoolIsVideoFile(name))
				return oftVIDEO;	
			else if (CoolIsUpkFile(name))
				return oftUPK;
			else if (CoolIsExecFile(name))
				return oftEXECUTABLE;
			else if (CoolIsPlaylistFile(name))
				return oftPLAYLIST;
			else if (CoolIsThemeFile(name))
				return oftTHEME;
		}
	}	
	return oftFILE;
}
Exemple #8
0
TbBool setup_move_to_new_workshop_position(struct Thing *thing, struct Room *room, unsigned long a3)
{
    struct CreatureControl *cctrl;
    SubtlCodedCoords stl_num;
    cctrl = creature_control_get_from_thing(thing);
    if ( a3 )
        cctrl->byte_9E = 50;
    cctrl->byte_9A = 1;
    stl_num = find_position_around_in_room(&thing->mappos, thing->owner, room->kind);
    if (stl_num <= 0)
    {
        WARNLOG("Could not find position around in %s of %d slabs",room_code_name(room->kind),(int)room->slabs_count);
        return false;
    }
    return setup_workshop_move(thing,stl_num);
}
short barracking(struct Thing *creatng)
{
    struct Room *room;
    room = get_room_thing_is_on(creatng);
    if (!room_still_valid_as_type_for_thing(room, RoK_BARRACKS, creatng))
    {
        WARNLOG("Room %s owned by player %d is bad work place for %s index %d owner %d",room_code_name(room->kind),(int)room->owner,thing_model_name(creatng),(int)creatng->index,(int)creatng->owner);
        remove_creature_from_work_room(creatng);
        set_start_state(creatng);
        return CrStRet_ResetFail;
    }
    if (person_move_somewhere_adjacent_in_room(creatng, room)) {
        creatng->continue_state = CrSt_Barracking;
    }
    return CrStRet_Modified;
}
Exemple #10
0
/** Open RTC device
 */
int CoolOpenRTC(void)
{
	static int fd = 0;

	if (!fd)
	{
		fd = open(RTC_DEV, O_RDWR);
		if (fd < 0)
		{
			fd = 0;
			WARNLOG("error opening %s\n", RTC_DEV);
			return -1;
		}
	}
	return fd;
}
bool MouseStateHandler::SetMousePointer(struct TbSprite *mouseSprite)
{
    LbSemaLock semlock(&semaphore,0);
    if (!semlock.Lock(true))
      return false;
    if (mouseSprite == lbDisplay.MouseSprite)
      return true;
    if (mouseSprite != NULL)
      if ( (mouseSprite->SWidth > 64) || (mouseSprite->SHeight > 64) )
      {
        WARNLOG("Mouse pointer too large");
        return false;
      }
    lbDisplay.MouseSprite = mouseSprite;
    this->SetPointer(mouseSprite, NULL);
    return true;
}
CLocalDataLogger::CLocalDataLogger(IPropertyTree *cfg, const char *process, const char *service, const char* UrlRoot)
{
    StringBuffer _directoryCache,xpath;
    
    xpath.appendf("Software/EspProcess[@name=\"%s\"]/EspService[@name=\"%s\"]/localCache/", process, service);
    IPropertyTree* cacheprop = cfg->queryBranch(xpath.str());
    if(cacheprop==0)
    {
        WARNLOG(-1,"No local cache defined for %s service.",service);
        return;
    }
    Init(cacheprop->queryProp("@cache"),cacheprop->queryProp("@fileExtension"),UrlRoot,cacheprop->getPropInt("@timerPeriod"),cacheprop->getPropInt("@cacheTimeout"));




}
/**
 * Setups a wanderer creature to move to a random thing in given list.
 * @param first_thing_idx
 * @param wanderer
 * @return
 */
TbBool setup_wanderer_move_to_random_creature_from_list(long first_thing_idx, struct Thing *wanderer)
{
    long possible_targets,target_match;
    possible_targets = get_wanderer_possible_targets_count_in_list(first_thing_idx,wanderer);
    // Select random target
    if (possible_targets < 1) {
        SYNCDBG(4,"The %s cannot wander to creature, there are no targets",thing_model_name(wanderer));
        return false;
    }
    target_match = ACTION_RANDOM(possible_targets);
    if ( wander_to_specific_possible_target_in_list(first_thing_idx, wanderer, target_match) )
    {
        return true;
    }
    WARNLOG("The %s index %d cannot wander to creature, it seem all %d creatures were not navigable",
        thing_model_name(wanderer),(int)wanderer->index,(int)possible_targets);
    return false;
}
    void CleanFiles()
    {
        //DBGLOG("directory len %d and ext len: %d",Directory.length(),Ext.length());
        
        if (Directory.length() == 0 || Ext.length() == 0)
            return;

        CDateTime currentTime;
        currentTime.setNow();

        int fileCounter = 0;
//      DBGLOG("Directory:%s for files of ext:%s",Directory.str(), Ext.str());
        Owned<IDirectoryIterator> di = createDirectoryIterator(Directory.str(), Ext.str());
        ForEach (*di)
        {
            IFile &file = di->query();
        
            CDateTime createTime, modifiedTime,accessedTime;
            file.getTime( &createTime,  &modifiedTime, &accessedTime);

            StringBuffer accessedTimeStr,currentTimeStr;
            accessedTime.getString(accessedTimeStr);
        
            accessedTime.adjustTime(+m_CacheTimeoutPeriod);
            accessedTimeStr.clear();

            accessedTime.getString(accessedTimeStr);
            
            currentTime.getString(currentTimeStr);

            if (accessedTime.compare(currentTime) < 0)
            {
                const char* fileName = file.queryFilename();
                DBGLOG("Trying to remove:%s",fileName);
                if (file.exists() == true)
                {
                    fileCounter++;
                    bool bDeleteOk = file.remove();
                    if (!bDeleteOk)
                        WARNLOG("ERROR Removing old cache file %s",fileName);
                }
            }
        }
    }
long load_static_light_file(unsigned long lv_num)
{
    unsigned long i;
    long k;
    long total;
    unsigned char *buf;
    struct InitLight ilght;
    long fsize;
    fsize = 4;
    buf = load_single_map_file_to_buffer(lv_num,"lgt",&fsize,LMFF_Optional);
    if (buf == NULL)
        return false;
    light_initialise();
    i = 0;
    total = llong(&buf[i]);
    i += 4;
    // Validate total amount of lights
    if ((total < 0) || (total > (fsize-4)/sizeof(struct InitLight)))
    {
        total = (fsize-4)/sizeof(struct InitLight);
        WARNMSG("Bad amount of static lights in LGT file; corrected to %ld.",total);
    }
    if (total >= LIGHTS_COUNT)
    {
        WARNMSG("Only %d static lights supported, LGT file has %ld.",LIGHTS_COUNT,total);
        total = LIGHTS_COUNT-1;
    } else
    if (total >= LIGHTS_COUNT/2)
    {
        WARNMSG("More than %d%% of light slots used by static lights.",100*total/LIGHTS_COUNT);
    }
    // Create the lights
    for (k=0; k < total; k++)
    {
        LbMemoryCopy(&ilght, &buf[i], sizeof(struct InitLight));
        if (light_create_light(&ilght) == 0)
        {
            WARNLOG("Couldn't allocate static light %d",(int)k);
        }
        i += sizeof(struct InitLight);
    }
    LbMemoryFree(buf);
    return true;
}
TbBool setup_head_for_random_unused_lair_slab(struct Thing *creatng, struct Room *room)
{
    SlabCodedCoords slbnum;
    long n;
    unsigned long k;
    n = ACTION_RANDOM(room->slabs_count);
    slbnum = room->slabs_list;
    for (k = n; k > 0; k--)
    {
        if (slbnum == 0)
            break;
        slbnum = get_next_slab_number_in_room(slbnum);
    }
    if (slbnum == 0) {
        ERRORLOG("Taking random slab (%d/%d) in %s index %d failed - internal inconsistency.",(int)n,(int)room->slabs_count,room_code_name(room->kind),(int)room->index);
        slbnum = room->slabs_list;
    }
    k = 0;
    while (1)
    {
        MapSlabCoord slb_x,slb_y;
        slb_x = slb_num_decode_x(slbnum);
        slb_y = slb_num_decode_y(slbnum);
        struct Thing *lairtng;
        lairtng = find_creature_lair_at_subtile(slab_subtile_center(slb_x), slab_subtile_center(slb_y), 0);
        if (thing_is_invalid(lairtng))
        {
            if (setup_person_move_to_position(creatng, slab_subtile_center(slb_x), slab_subtile_center(slb_y), NavRtF_Default)) {
                return true;
            }
            WARNLOG("Cannot get somewhere in room");
        }
        slbnum = get_next_slab_number_in_room(slbnum);
        if (slbnum == 0) {
            slbnum = room->slabs_list;
        }
        k++;
        if (k >= room->slabs_count) {
            break;
        }
    }
    return false;
}
/*----------------------------------------------------------------------------*/
WLAN_STATUS
wlanoidSetP2pPowerSaveProfile(IN P_ADAPTER_T prAdapter,
			      IN PVOID pvSetBuffer,
			      IN UINT_32 u4SetBufferLen, OUT PUINT_32 pu4SetInfoLen)
{
	WLAN_STATUS status;
	PARAM_POWER_MODE ePowerMode;
	DEBUGFUNC("wlanoidSetP2pPowerSaveProfile");

	ASSERT(prAdapter);
	ASSERT(pu4SetInfoLen);

	*pu4SetInfoLen = sizeof(PARAM_POWER_MODE);
	if (u4SetBufferLen < sizeof(PARAM_POWER_MODE)) {
		DBGLOG(REQ, WARN, ("Invalid length %ld\n", u4SetBufferLen));
		return WLAN_STATUS_INVALID_LENGTH;
	} else if (*(PPARAM_POWER_MODE) pvSetBuffer >= Param_PowerModeMax) {
		WARNLOG(("Invalid power mode %d\n", *(PPARAM_POWER_MODE) pvSetBuffer));
		return WLAN_STATUS_INVALID_DATA;
	}

	ePowerMode = *(PPARAM_POWER_MODE) pvSetBuffer;

	if (prAdapter->fgEnCtiaPowerMode) {
		if (ePowerMode == Param_PowerModeCAM) {

		} else {
			/* User setting to PS mode (Param_PowerModeMAX_PSP or Param_PowerModeFast_PSP) */

			if (prAdapter->u4CtiaPowerMode == 0) {
				/* force to keep in CAM mode */
				ePowerMode = Param_PowerModeCAM;
			} else if (prAdapter->u4CtiaPowerMode == 1) {
				ePowerMode = Param_PowerModeMAX_PSP;
			} else if (prAdapter->u4CtiaPowerMode == 2) {
				ePowerMode = Param_PowerModeFast_PSP;
			}
		}
	}

	status = nicConfigPowerSaveProfile(prAdapter, NETWORK_TYPE_P2P_INDEX, ePowerMode, TRUE);
	return status;
}				/* end of wlanoidSetP2pPowerSaveProfile() */
bool MouseStateHandler::SetMousePointerAndOffset(struct TbSprite *mouseSprite, long x, long y)
{
    struct TbPoint point;
    LbSemaLock semlock(&semaphore,0);
    if (!semlock.Lock(true))
      return false;
    if (mouseSprite == lbDisplay.MouseSprite)
      return true;
    if (mouseSprite != NULL)
      if ( (mouseSprite->SWidth > 64) || (mouseSprite->SHeight > 64) )
      {
        WARNLOG("Mouse pointer too large");
        return false;
      }
    lbDisplay.MouseSprite = mouseSprite;
    point.x = x;
    point.y = y;
    return this->SetPointer(mouseSprite, &point);
}
/**
 * Returns if the given bonus level is visible in land view screen.
 */
TbBool is_bonus_level_visible(struct PlayerInfo *player, LevelNumber bn_lvnum)
{
  int i,n,k;
  i = storage_index_for_bonus_level(bn_lvnum);
  if (i < 0)
  {
      // This hapens quite often - status of bonus level is checked even
      // if there's no such bonus level. So no log message here.
      return false;
  }
  n = i/8;
  k = (1 << (i%8));
  if ((n < 0) || (n >= BONUS_LEVEL_STORAGE_COUNT))
  {
    WARNLOG("Bonus level %d has invalid store position.",(int)bn_lvnum);
    return false;
  }
  return ((intralvl.bonuses_found[n] & k) != 0);
}
TbBool good_setup_wander_to_exit(struct Thing *creatng)
{
    struct Thing *gatetng;
    SYNCDBG(7,"Starting");
    gatetng = find_hero_door_hero_can_navigate_to(creatng);
    if (thing_is_invalid(gatetng))
    {
        SYNCLOG("Can't find any exit gate for hero %s.",thing_model_name(creatng));
        return false;
    }
    if (!setup_person_move_to_coord(creatng, &gatetng->mappos, NavRtF_Default))
    {
        WARNLOG("Hero %s index %d can't move to exit gate at (%d,%d).",thing_model_name(creatng),
            (int)gatetng->index, (int)gatetng->mappos.x.stl.num, (int)gatetng->mappos.y.stl.num);
        return false;
    }
    creatng->continue_state = CrSt_GoodLeaveThroughExitDoor;
    return true;
}
short at_research_room(struct Thing *thing)
{
    struct CreatureControl *cctrl;
    struct Dungeon *dungeon;
    struct Room *room;
    cctrl = creature_control_get_from_thing(thing);
    cctrl->target_room_id = 0;
    dungeon = get_dungeon(thing->owner);
    if (!creature_can_do_research(thing))
    {
        if (!is_neutral_thing(thing) && (dungeon->current_research_idx < 0))
        {
            if (is_my_player_number(dungeon->owner))
                output_message(SMsg_NoMoreReseach, 500, true);
        }
        set_start_state(thing);
        return 0;
    }
    room = get_room_thing_is_on(thing);
    if (!room_initially_valid_as_type_for_thing(room, RoK_LIBRARY, thing))
    {
        WARNLOG("Room %s owned by player %d is invalid for %s index %d",room_code_name(room->kind),(int)room->owner,thing_model_name(thing),(int)thing->index);
        set_start_state(thing);
        return 0;
    }
    if (!add_creature_to_work_room(thing, room))
    {
        set_start_state(thing);
        return 0;
    }
    if (!setup_random_head_for_room(thing, room, NavRtF_Default))
    {
        ERRORLOG("The %s index %d can not move in research room", thing_model_name(thing),(int)thing->index);
        remove_creature_from_work_room(thing);
        set_start_state(thing);
        return 0;
    }
    thing->continue_state = CrSt_Researching;
    cctrl->field_82 = 0;
    cctrl->byte_9A = 3;
    return 1;
}
Exemple #22
0
struct Thing *get_creature_in_training_room_which_could_accept_partner(struct Room *room, struct Thing *partnertng)
{
    struct CreatureControl *cctrl;
    struct Thing *thing;
    unsigned long k;
    long i;
    TRACE_THING(partnertng);
    i = room->creatures_list;
    k = 0;
    while (i != 0)
    {
        thing = thing_get(i);
        TRACE_THING(thing);
        cctrl = creature_control_get_from_thing(thing);
        if (!creature_control_exists(cctrl))
        {
            ERRORLOG("Jump to invalid creature %d detected",(int)i);
            break;
        }
        i = cctrl->next_in_room;
        // Per creature code
        if (thing != partnertng)
        {
            if ( (get_creature_state_besides_move(thing) == CrSt_Training) && (cctrl->training.partner_idx == 0) )
            {
                if (get_room_thing_is_on(thing) == room) {
                    return thing;
                } else {
                    WARNLOG("The %s pretends to be in room but it's not.",thing_model_name(thing));
                }
            }
        }
        // Per creature code ends
        k++;
        if (k > THINGS_COUNT)
        {
          ERRORLOG("Infinite loop detected when sweeping creatures list");
          break;
        }
    }
    return INVALID_THING;
}
short at_lair_to_sleep(struct Thing *thing)
{
    struct CreatureControl *cctrl;
    struct Thing *lairtng;
    struct Room *room;
    TRACE_THING(thing);
    //return _DK_at_lair_to_sleep(thing);
    cctrl = creature_control_get_from_thing(thing);
    lairtng = thing_get(cctrl->lairtng_idx);
    TRACE_THING(lairtng);
    cctrl->target_room_id = 0;
    if (thing_is_invalid(lairtng) || (cctrl->slap_turns != 0))
    {
        set_start_state(thing);
        return 0;
    }
    if (!creature_will_sleep(thing))
    {
        set_start_state(thing);
        return 0;
    }
    room = get_room_thing_is_on(thing);
    if (!room_initially_valid_as_type_for_thing(room, RoK_LAIR, thing))
    {
        WARNLOG("Room %s owned by player %d is invalid for %s",room_code_name(room->kind),(int)room->owner,thing_model_name(thing));
        set_start_state(thing);
        return 0;
    }
    if ((cctrl->lair_room_id != room->index))
    {
        set_start_state(thing);
        return 0;
    }
    if ( !creature_turn_to_face_angle(thing, lairtng->field_52) )
    {
        internal_set_thing_state(thing, CrSt_CreatureSleep);
        cctrl->field_82 = 200;
        thing->movement_flags &= ~TMvF_Flying;
    }
    process_lair_enemy(thing, room);
    return 1;
}
bool CRpcResponse::handleExceptions(IXslProcessor *xslp, IMultiException *me, const char *serv, const char *meth, const char *errorXslt)
{
    IEspContext *context=queryContext();
    if (me->ordinality()>0)
    {
        StringBuffer text;
        me->errorMessage(text);
        text.append('\n');
        WARNLOG("Exception(s) in %s::%s - %s", serv, meth, text.str());

        if (errorXslt)
        {
            me->serialize(text.clear());
            StringBuffer theOutput;
            xslTransformHelper(xslp, text.str(), errorXslt, theOutput, context->queryXslParameters());
            set_text(theOutput.str());
        }
    }
    return false;
}
CrStateRet creature_at_new_lair(struct Thing *creatng)
{
    struct Room *room;
    TRACE_THING(creatng);
    //return _DK_creature_at_new_lair(thing);
    room = get_room_thing_is_on(creatng);
    if ( !room_still_valid_as_type_for_thing(room, RoK_LAIR, creatng) )
    {
        WARNLOG("Room %s owned by player %d is bad work place for %s owned by played %d",room_code_name(room->kind),(int)room->owner,thing_model_name(creatng),(int)creatng->owner);
        set_start_state(creatng);
        return CrStRet_ResetFail;
    }
    if (!creature_add_lair_to_room(creatng, room))
    {
        internal_set_thing_state(creatng, CrSt_CreatureChooseRoomForLairSite);
        return CrStRet_Modified;
    }
    set_start_state(creatng);
    return CrStRet_ResetOk;
}
Exemple #26
0
short at_training_room(struct Thing *thing)
{
    struct CreatureControl *cctrl;
    struct CreatureStats *crstat;
    struct Dungeon *dungeon;
    struct Room *room;
    //return _DK_at_training_room(thing);
    cctrl = creature_control_get_from_thing(thing);
    cctrl->target_room_id = 0;
    if (!creature_can_be_trained(thing))
    {
        SYNCDBG(9,"Ending training of %s level %d; creature is not trainable",thing_model_name(thing),(int)cctrl->explevel);
        set_start_state(thing);
        return 0;
    }
    crstat = creature_stats_get_from_thing(thing);
    dungeon = get_dungeon(thing->owner);
    if (dungeon->total_money_owned < crstat->training_cost)
    {
        if (is_my_player_number(thing->owner))
            output_message(SMsg_NoGoldToTrain, MESSAGE_DELAY_TREASURY, true);
        set_start_state(thing);
        return 0;
    }
    room = get_room_thing_is_on(thing);
    if (!room_initially_valid_as_type_for_thing(room, RoK_TRAINING, thing))
    {
        WARNLOG("Room %s owned by player %d is invalid for %s",room_code_name(room->kind),(int)room->owner,thing_model_name(thing));
        set_start_state(thing);
        return 0;
    }
    if ( !add_creature_to_work_room(thing, room) )
    {
        set_start_state(thing);
        return 0;
    }
    internal_set_thing_state(thing, CrSt_Training);
    setup_move_to_new_training_position(thing, room, 1);
    cctrl->field_82 = 0;
    return 1;
}
short at_barrack_room(struct Thing *creatng)
{
    struct Room *room;
    struct CreatureControl *cctrl;
    cctrl = creature_control_get_from_thing(creatng);
    cctrl->target_room_id = 0;
    room = get_room_thing_is_on(creatng);
    if (!room_initially_valid_as_type_for_thing(room, RoK_BARRACKS, creatng))
    {
        WARNLOG("Room %s owned by player %d is invalid for %s index %d",room_code_name(room->kind),(int)room->owner,thing_model_name(creatng),(int)creatng->index);
        set_start_state(creatng);
        return 0;
    }
    if (!add_creature_to_work_room(creatng, room))
    {
        set_start_state(creatng);
        return 0;
    }
    internal_set_thing_state(creatng, CrSt_Barracking);
    return 1;
}
Exemple #28
0
TbBool erstat_check(void)
{
    int stat_num,sdiff;
    // Don't check more often than every 7 turns
    if ((game.play_gameturn & 0x07) != 0)
        return false;
    stat_num = last_checked_stat_num;
    sdiff = erstat[stat_num].n - erstat[stat_num].nprv;
    // Display an error if any things were not created in this game turn
    if (sdiff != 0)
    {
#if (BFDEBUG_LEVEL > 0)
        show_onscreen_msg(game.num_fps,"%s, %ld occurrences",erstat[stat_num].msg,sdiff);
#else
        WARNLOG("%s, %ld occurrences",erstat[stat_num].msg,sdiff);
#endif
        erstat[stat_num].nprv = erstat[stat_num].n;
    }
    last_checked_stat_num = (last_checked_stat_num+1) % (sizeof(erstat)/sizeof(erstat[0]));
    return (sdiff != 0);
}
Exemple #29
0
    CKeyReader(char const * filename) : count(0)
    {
        keyFile.setown(createIFile(filename));
        keyFileIO.setown(keyFile->open(IFOread));
        if(!keyFileIO)
            throw MakeStringException(0, "Could not read index file %s", filename);
        keyIndex.setown(createKeyIndex(filename, 0, *keyFileIO, false, false)); // MORE - should we care about crc?
        unsigned flags = keyIndex->getFlags();
        variableWidth = ((flags & HTREE_VARSIZE) == HTREE_VARSIZE);
        if((flags & HTREE_QUICK_COMPRESSED_KEY) == HTREE_QUICK_COMPRESSED_KEY)
            quickCompressed = true;
        else if((flags & HTREE_COMPRESSED_KEY) == HTREE_COMPRESSED_KEY)
            quickCompressed = false;
        else
            throw MakeStringException(0, "Index file %s did not have compression flags set, unsupported", filename);
        unsigned optionalFlags = (HTREE_VARSIZE | HTREE_QUICK_COMPRESSED_KEY | HTREE_TOPLEVEL_KEY | HTREE_FULLSORT_KEY);
        unsigned requiredFlags = COL_PREFIX;
#ifdef _DEBUG
        if((flags & ~optionalFlags) != requiredFlags)
            ERRLOG("Index file %s did not have expected index flags set (%x)", filename, (flags & ~optionalFlags) );
#else
        if((flags & ~optionalFlags) != requiredFlags)
            throw MakeStringException(0, "Index file %s did not have expected index flags set (%x)", filename, (flags & ~optionalFlags) );
#endif
        offset_t blobHead = keyIndex->queryBlobHead();
        if(blobHead == static_cast<offset_t>(-1))
            WARNLOG("Index part %s does not declare blob status: if it contains blobs, they will be lost", filename);
        else if(blobHead != 0)
            throw MakeStringException(0, "Index contains BLOBs, which are currently not supported by keydiff/patch");
        if(keyIndex->queryMetadataHead())
            throw MakeStringException(0, "Index contains metadata, which is not currently supported by keydiff/patch");
        keyCursor.setown(keyIndex->getCursor(NULL));
        if(keyIndex->hasPayload())
            keyedsize = keyIndex->keyedSize();
        else
            keyedsize = static_cast<unsigned>(-1);
        rowsize = keyIndex->keySize();
        eof = false;
    }
void multiply_creatures_in_dungeon_list(struct Dungeon *dungeon, long list_start)
{
    struct Thing *thing;
    struct Thing *tncopy;
    struct CreatureControl *cctrl;
    unsigned long k;
    int i;
    k = 0;
    i = list_start;
    while (i != 0)
    {
        thing = thing_get(i);
        cctrl = creature_control_get_from_thing(thing);
        if (thing_is_invalid(thing) || creature_control_invalid(cctrl))
        {
            ERRORLOG("Jump to invalid creature detected");
            break;
        }
        i = cctrl->players_next_creature_idx;
        // Thing list loop body
        tncopy = create_creature(&thing->mappos, thing->model, dungeon->owner);
        if (thing_is_invalid(tncopy))
        {
            WARNLOG("Can't create a copy of creature");
            break;
        }
        set_creature_level(tncopy, cctrl->explevel);
        tncopy->health = thing->health;
        // Thing list loop body ends
        k++;
        if (k > CREATURES_COUNT)
        {
            ERRORLOG("Infinite loop detected when sweeping creatures list");
            erstat_inc(ESE_InfChainTngPerOwner);
            break;
        }
    }
}