Esempio n. 1
0
/* ask_confirm() adapted from programs/cmd/builtins.c */
static BOOL ask_confirm(unsigned int msgid, WCHAR *reg_info)
{
    HMODULE hmod;
    WCHAR Ybuffer[4];
    WCHAR Nbuffer[4];
    WCHAR defval[32];
    WCHAR answer[MAX_PATH];
    DWORD count;

    hmod = GetModuleHandleW(NULL);
    LoadStringW(hmod, STRING_YES, Ybuffer, ARRAY_SIZE(Ybuffer));
    LoadStringW(hmod, STRING_NO,  Nbuffer, ARRAY_SIZE(Nbuffer));
    LoadStringW(hmod, STRING_DEFAULT_VALUE, defval, ARRAY_SIZE(defval));

    while (1)
    {
        output_message(msgid, reg_info ? reg_info : defval);
        output_message(STRING_YESNO);
        ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), answer, ARRAY_SIZE(answer), &count, NULL);
        answer[0] = toupperW(answer[0]);
        if (answer[0] == Ybuffer[0])
            return TRUE;
        if (answer[0] == Nbuffer[0])
            return FALSE;
    }
}
Esempio n. 2
0
/**
 * Does a step of being imprisoned.
 * Informs if the imprisoning cycle should end.
 * @param thing
 */
CrCheckRet process_prison_function(struct Thing *creatng)
{
  struct Room *room;
  room = get_room_creature_works_in(creatng);
  if (!room_still_valid_as_type_for_thing(room, RoK_PRISON, 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);
      set_start_state(creatng);
      return CrCkRet_Continue;
  }
  process_creature_hunger(creatng);
  if ( process_prisoner_skelification(creatng,room) )
    return CrCkRet_Deleted;
  struct CreatureControl *cctrl;
  cctrl = creature_control_get_from_thing(creatng);
  if ((cctrl->instance_id == CrInst_NULL) && process_prison_food(creatng, room) )
    return CrCkRet_Continue;
  // Breaking from jail is only possible once per some amount of turns
  if ((game.play_gameturn % gameadd.time_between_prison_break) == 0)
  {
      if (jailbreak_possible(room, creatng->owner))
      {
          if (is_my_player_number(room->owner))
              output_message(SMsg_PrisonersEscaping, 40, true);
          else if (is_my_player_number(room->owner))
              output_message(SMsg_CreatrFreedPrison, 40, true);
          set_start_state(creatng);
          return CrCkRet_Continue;
      }
  }
  return CrCkRet_Available;
}
Esempio n. 3
0
/* create edit */
void cmd_ce (int argc, char *argv[])
{
	struct stat st_buf;
	pad_t  *pad;
	int r;

	if (argc == 1) {
		output_message_c (argv[0], "Missing File Name");
		return;
	}

	r = stat (argv[1], &st_buf);
	if (r != 0 && errno != ENOENT) {
		output_message("%s : %s", argv[1], strerror(errno));
		return;
	}
	if (S_ISDIR (st_buf.st_mode))
	{
		output_message ("%s : is a directory", argv[1]);
		return;
	}

	pad = pad_add();

	if (!crash_file_check (pad, argv[1])) {
		pad_read_file(pad, argv[1]);
		display_filename(pad->filename);
	}
}
Esempio n. 4
0
/******************************************************************************
 * This function is a wrapper for the setValue function.  It prepares the
 * land and cleans the area once completed.
 * Note: this function modifies the line parameter.
 *
 * line - registry file unwrapped line. Should have the registry value name and
 *      complete registry value data.
 */
static void processSetValue(WCHAR* line, BOOL is_unicode)
{
    WCHAR* val_name;                   /* registry value name   */
    WCHAR* val_data;                   /* registry value data   */
    int line_idx = 0;                 /* current character under analysis */
    LONG res;

    /* get value name */
    while ( isspaceW(line[line_idx]) ) line_idx++;
    if (line[line_idx] == '@' && line[line_idx + 1] == '=') {
        line[line_idx] = '\0';
        val_name = line;
        line_idx++;
    } else if (line[line_idx] == '\"') {
        line_idx++;
        val_name = line + line_idx;
        while (line[line_idx]) {
            if (line[line_idx] == '\\')   /* skip escaped character */
            {
                line_idx += 2;
            } else {
                if (line[line_idx] == '\"') {
                    line[line_idx] = '\0';
                    line_idx++;
                    break;
                } else {
                    line_idx++;
                }
            }
        }
        while ( isspaceW(line[line_idx]) ) line_idx++;
        if (!line[line_idx]) {
            output_message(STRING_UNEXPECTED_EOL, line);
            return;
        }
        if (line[line_idx] != '=') {
            line[line_idx] = '\"';
            output_message(STRING_UNRECOGNIZED_LINE, line);
            return;
        }

    } else {
        output_message(STRING_UNRECOGNIZED_LINE, line);
        return;
    }
    line_idx++;                   /* skip the '=' character */

    while ( isspaceW(line[line_idx]) ) line_idx++;
    val_data = line + line_idx;
    /* trim trailing blanks */
    line_idx = strlenW(val_data);
    while (line_idx > 0 && isspaceW(val_data[line_idx-1])) line_idx--;
    val_data[line_idx] = '\0';

    REGPROC_unescape_string(val_name);
    res = setValue(val_name, val_data, is_unicode);
    if ( res != ERROR_SUCCESS )
        output_message(STRING_SETVALUE_FAILED, val_name, currentKeyName);
}
Esempio n. 5
0
long attempt_anger_job(struct Thing *creatng, long ajob_kind)
{
    switch (ajob_kind)
    {
    case 1:
        if (!attempt_anger_job_kill_creatures(creatng))
            break;
        return true;
    case 2:
        if (!attempt_anger_job_destroy_rooms(creatng))
            break;
        if (is_my_player_number(creatng->owner))
            output_message(SMsg_CreatrDestroyRooms, 500, 1);
        return true;
    case 4:
        if (!attempt_anger_job_leave_dungeon(creatng))
            break;
        if (is_my_player_number(creatng->owner))
            output_message(SMsg_CreatureLeaving, 500, 1);
        return true;
    case 8:
        if (!attempt_anger_job_steal_gold(creatng))
            break;
        return true;
    case 16:
        if (!attempt_anger_job_damage_walls(creatng))
            break;
        if (is_my_player_number(creatng->owner))
            output_message(SMsg_CreatrDestroyRooms, 500, 1);
        return true;
    case 32:
        if (!attempt_anger_job_mad_psycho(creatng))
            break;
        return true;
    case 64:
        if (!attempt_anger_job_persuade(creatng)) {
            // If can't init persuade, then leave alone
            if (!attempt_anger_job_leave_dungeon(creatng))
                break;
            if (is_my_player_number(creatng->owner))
                output_message(SMsg_CreatureLeaving, 500, 1);
        }
        return true;
    case 128:
        if (!attempt_anger_job_join_enemy(creatng))
            break;
        return true;
    default:
        break;
    }
    return false;
}
Esempio n. 6
0
TbBool output_message_room_related_from_computer_or_player_action(PlayerNumber plyr_idx, RoomKind rkind, OutputMessageKind msg_kind)
{
    if (!is_my_player_number(plyr_idx)) {
        return false;
    }
    const struct RoomConfigStats *roomst;
    roomst = get_room_kind_stats(rkind);
    long delay, msg_idx;
    switch (msg_kind)
    {
    case OMsg_RoomNeeded:
        msg_idx = roomst->msg_needed;
        delay = MESSAGE_DELAY_ROOM_NEED;
        break;
    case OMsg_RoomTooSmall:
        msg_idx = roomst->msg_too_small;
        delay = MESSAGE_DELAY_ROOM_SMALL;
        break;
    case OMsg_RoomNoRoute:
        msg_idx = roomst->msg_no_route;
        delay = MESSAGE_DELAY_ROOM_NEED;
        break;
    default:
        msg_idx = 0;
        delay = 0;
        break;
    }
    if (msg_idx < 1) {
        return false;
    }
    return output_message(msg_idx, delay, true);
}
Esempio n. 7
0
/** Process an incoming main loop control request
    @returns non-zero on success, 0 on failure (errno set)
 **/
int http_control_request(HTTPCNX *http, char *action)
{
	char buffer[1024];

	if ( strcmp(action,"resume")==0 )
	{
		exec_mls_resume(TS_NEVER);
		return 1;
	}
	else if ( sscanf(action,"pauseat=%[-0-9%:A-Za-z]",buffer)==1 )
	{
		TIMESTAMP ts;
		http_decode(buffer);
		ts = convert_to_timestamp(buffer);
		if ( ts!=TS_INVALID )
		{
			exec_mls_resume(ts);
			return 1;
		}
		else
		{
			output_error("control command '%s' has an invalid timestamp", buffer);
			return 0;
		}
	}
	else if ( strcmp(action,"shutdown")==0 )
	{
		output_message("server shutdown by client");
		exit(XC_SUCCESS);
	}
	return 0;
}
short at_scavenger_room(struct Thing *thing)
{
    struct CreatureControl *cctrl;
    struct CreatureStats *crstat;
    struct Dungeon *dungeon;
    struct Room *room;
    //return _DK_at_scavenger_room(thing);
    room = get_room_thing_is_on(thing);
    if (!room_initially_valid_as_type_for_thing(room, RoK_SCAVENGER, 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;
    }
    cctrl = creature_control_get_from_thing(thing);
    crstat = creature_stats_get_from_thing(thing);
    dungeon = get_dungeon(thing->owner);
    if (crstat->scavenger_cost >= dungeon->total_money_owned)
    {
        if (is_my_player_number(thing->owner))
            output_message(SMsg_NoGoldToScavenge, MESSAGE_DELAY_TREASURY, true);
        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_Scavengering);
    cctrl->field_82 = 0;
    return 1;
}
Esempio n. 9
0
/******************************************************************************
 * Converts a hex comma separated values list into a binary string.
 */
static BYTE* convertHexCSVToHex(WCHAR *str, DWORD *size)
{
    WCHAR *s;
    BYTE *d, *data;

    /* The worst case is 1 digit + 1 comma per byte */
    *size=(lstrlenW(str)+1)/2;
    data=HeapAlloc(GetProcessHeap(), 0, *size);
    CHECK_ENOUGH_MEMORY(data);

    s = str;
    d = data;
    *size=0;
    while (*s != '\0') {
        UINT wc;
        WCHAR *end;

        wc = strtoulW(s,&end,16);
        if (end == s || wc > 0xff || (*end && *end != ',')) {
            output_message(STRING_CSV_HEX_ERROR, s);
            HeapFree(GetProcessHeap(), 0, data);
            return NULL;
        }
        *d++ =(BYTE)wc;
        (*size)++;
        if (*end) end++;
        s = end;
    }

    return data;
}
Esempio n. 10
0
/** Displays the current legal banner
	@return SUCCESS when conditions of use have been satisfied, FAILED when conditions of use have not been satisfied
 **/
STATUS legal_notice(void)
{
	char *buildinfo = strstr(BUILD,":");

	/* suppress copyright info if copyright file exists */
	char copyright[1024] = "GridLAB-D " COPYRIGHT;
	char *end = strchr(copyright,'\n');
	int suppress = global_suppress_repeat_messages;
	char path[1024];
	global_suppress_repeat_messages = 0;
	while ((end = strchr(copyright,'\n'))!=NULL) {
		*end = ' ';
	}
	if (find_file(copyright,NULL,R_OK,path,sizeof(path))==NULL)
	{
		int build = buildinfo ? atoi(strstr(BUILD,":")+1) : 0;
		output_message("GridLAB-D %d.%d.%d-%d (%s) %d-bit %s %s\n%s", 
			global_version_major, global_version_minor, global_version_patch, global_version_build, 
			global_version_branch, 8*sizeof(void*), global_platform,
#ifdef _DEBUG
		"DEBUG",
#else
		"RELEASE",
#endif
		COPYRIGHT);
	}
	global_suppress_repeat_messages = suppress;
	return SUCCESS; /* conditions of use have been met */
}
Esempio n. 11
0
/******************************************************************************
 * Replaces escape sequences with the characters.
 */
static int REGPROC_unescape_string(WCHAR* str)
{
    int str_idx = 0;            /* current character under analysis */
    int val_idx = 0;            /* the last character of the unescaped string */
    int len = lstrlenW(str);
    for (str_idx = 0; str_idx < len; str_idx++, val_idx++) {
        if (str[str_idx] == '\\') {
            str_idx++;
            switch (str[str_idx]) {
            case 'n':
                str[val_idx] = '\n';
                break;
            case 'r':
                str[val_idx] = '\r';
                break;
            case '0':
                str[val_idx] = '\0';
                break;
            case '\\':
            case '"':
                str[val_idx] = str[str_idx];
                break;
            default:
                output_message(STRING_ESCAPE_SEQUENCE, str[str_idx]);
                str[val_idx] = str[str_idx];
                break;
            }
        } else {
            str[val_idx] = str[str_idx];
        }
    }
    str[val_idx] = '\0';
    return val_idx;
}
Esempio n. 12
0
/******************************************************************************
 * Open file in binary mode for export.
 */
static FILE *REGPROC_open_export_file(WCHAR *file_name, BOOL unicode)
{
    FILE *file;
    WCHAR dash = '-';

    if (strncmpW(file_name,&dash,1)==0) {
        file=stdout;
        _setmode(_fileno(file), _O_BINARY);
    } else
    {
        WCHAR wb_mode[] = {'w','b',0};
        WCHAR regedit[] = {'r','e','g','e','d','i','t',0};

        file = _wfopen(file_name, wb_mode);
        if (!file) {
            _wperror(regedit);
            output_message(STRING_CANNOT_OPEN_FILE, file_name);
            exit(1);
        }
    }
    if(unicode)
    {
        const BYTE unicode_seq[] = {0xff,0xfe};
        const WCHAR header[] = {'W','i','n','d','o','w','s',' ','R','e','g','i','s','t','r','y',' ','E','d','i','t','o','r',' ','V','e','r','s','i','o','n',' ','5','.','0','0','\r','\n'};
        fwrite(unicode_seq, sizeof(BYTE), sizeof(unicode_seq)/sizeof(unicode_seq[0]), file);
        fwrite(header, sizeof(WCHAR), sizeof(header)/sizeof(header[0]), file);
    } else
    {
        fputs("REGEDIT4\r\n", file);
    }

    return file;
}
Esempio n. 13
0
static HANDLE get_file_handle(WCHAR *filename, BOOL overwrite_file)
{
    HANDLE hFile = create_file(filename, overwrite_file ? CREATE_ALWAYS : CREATE_NEW);

    if (hFile == INVALID_HANDLE_VALUE)
    {
        DWORD error = GetLastError();

        if (error == ERROR_FILE_EXISTS)
        {
            if (!ask_confirm(STRING_OVERWRITE_FILE, filename))
            {
                output_message(STRING_CANCELLED);
                exit(0);
            }

            hFile = create_file(filename, CREATE_ALWAYS);
        }
        else
        {
            WCHAR *str;

            FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
                           FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, 0, (WCHAR *)&str, 0, NULL);
            output_writeconsole(str, lstrlenW(str));
            LocalFree(str);
            exit(1);
        }
    }

    return hFile;
}
Esempio n. 14
0
void transfer_creature(struct Thing *boxtng, struct Thing *transftng, unsigned char plyr_idx)
{
    SYNCDBG(7,"Starting");
    struct CreatureControl *cctrl;
    if (!thing_exists(boxtng) || (box_thing_to_special(boxtng) != SpcKind_TrnsfrCrtr) ) {
        ERRORMSG("Invalid transfer box object!");
        return;
    }
    // Check if 'things' are correct
    if (!thing_exists(transftng) || !thing_is_creature(transftng) || (transftng->owner != plyr_idx)) {
        ERRORMSG("Invalid transfer creature thing!");
        return;
    }

    cctrl = creature_control_get_from_thing(transftng);
    set_transfered_creature(plyr_idx, transftng->model, cctrl->explevel);
    remove_thing_from_power_hand_list(transftng, plyr_idx);
    kill_creature(transftng, INVALID_THING, -1, CrDed_NoEffects|CrDed_NotReallyDying);
    create_special_used_effect(&boxtng->mappos, plyr_idx);
    remove_events_thing_is_attached_to(boxtng);
    force_any_creature_dragging_owned_thing_to_drop_it(boxtng);
    delete_thing_structure(boxtng, 0);
    if (is_my_player_number(plyr_idx))
      output_message(SMsg_CommonAcknowledge, 0, true);
}
Esempio n. 15
0
CrCheckRet process_scavenge_function(struct Thing *calltng)
{
    SYNCDBG(18,"Starting for %s owner %d",thing_model_name(calltng),(int)calltng->owner);
    //return _DK_process_scavenge_function(thing);
    struct CreatureControl *callctrl;
    callctrl = creature_control_get_from_thing(calltng);
    struct Dungeon *calldngn;
    struct Room *room;
    calldngn = get_dungeon(calltng->owner);
    room = get_room_creature_works_in(calltng);
    if ( !room_still_valid_as_type_for_thing(room, RoK_SCAVENGER, calltng) )
    {
        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(calltng),(int)calltng->owner);
        set_start_state(calltng);
        return CrCkRet_Continue;
    }
    struct CreatureStats *crstat;
    crstat = creature_stats_get_from_thing(calltng);
    if (!player_can_afford_to_scavenge_creature(calltng))
    {
        if (is_my_player_number(calltng->owner))
            output_message(SMsg_NoGoldToScavenge, 500, 1);
        set_start_state(calltng);
        return CrCkRet_Continue;
    }
    if (calldngn->scavenge_counters_turn != game.play_gameturn)
    {
        reset_scavenge_counts(calldngn);
    }
    long work_value;
    work_value = compute_creature_work_value(crstat->scavenge_value*256, room->efficiency, callctrl->explevel);
    work_value = process_work_speed_on_work_value(calltng, work_value);
    SYNCDBG(9,"The %s index %d owner %d produced %d scavenge points",thing_model_name(calltng),(int)calltng->index,(int)calltng->owner,(int)work_value);
    struct Thing *scavtng;
    scavtng = get_scavenger_target(calltng);
    if (!thing_is_invalid(scavtng))
    {
        process_scavenge_creature_from_level(scavtng, calltng, work_value);
    } else
    if (can_scavenge_creature_from_pool(calldngn, calltng->model))
    {
        process_scavenge_creature_from_pool(calltng, work_value);
    } else
    {
        if (crstat->entrance_force) {
          calldngn->field_1485++;
        }
        return 0;
    }
    callctrl->field_82++;
    if (callctrl->field_82 > game.scavenge_cost_frequency)
    {
        callctrl->field_82 -= game.scavenge_cost_frequency;
        if (take_money_from_dungeon(calltng->owner, crstat->scavenger_cost, 1) < 0) {
            ERRORLOG("Cannot take %d gold from dungeon %d",(int)crstat->scavenger_cost,(int)calltng->owner);
        }
        create_price_effect(&calltng->mappos, calltng->owner, crstat->scavenger_cost);
    }
    return 0;
}
Esempio n. 16
0
void update_player_sounds(void)
{
    int k;
    struct PlayerInfo *player;
    SYNCDBG(7,"Starting");
    if ((game.operation_flags & GOF_Paused) == 0)
    {
        player = get_my_player();
        process_messages();
        if (!SoundDisabled)
        {
            if (game.audiotrack > 0)
            {
                PlayMusicPlayer(game.audiotrack);
            }
            update_3d_sound_receiver(player);
        }
        game.play_gameturn++;
    }
    find_nearest_rooms_for_ambient_sound();
    process_3d_sounds();
    k = (game.bonus_time-game.play_gameturn) / 2;
    if (bonus_timer_enabled())
    {
      if ((game.bonus_time == game.play_gameturn) ||
         ((game.bonus_time > game.play_gameturn) && (((k <= 100) && ((k % 10) == 0)) ||
          ((k<=300) && ((k % 50) == 0)) || ((k % 250) == 0))) )
        play_non_3d_sample(89);
    }
    // Rare message easter egg
    if ((game.play_gameturn != 0) && ((game.play_gameturn % 20000) == 0))
    {
        if (ACTION_RANDOM(2000) == 0)
        {
          k = UNSYNC_RANDOM(10);
          SYNCDBG(9,"Rare message condition met, selected %d",(int)k);
          if (k == 7)
          {
            output_message(SMsg_PantsTooTight, 0, true);
          } else
          {
            output_message(SMsg_FunnyMessages+k, 0, true);
          }
        }
    }
    SYNCDBG(9,"Finished");
}
Esempio n. 17
0
void ERROR_message( char *fmt , ... )
{
   va_list vararg_ptr ;
   va_start( vararg_ptr , fmt ) ;
   output_message( 1 , "** ERROR: " , fmt , vararg_ptr ) ;
   va_end( vararg_ptr ) ;
   return ;
}
Esempio n. 18
0
void WARNING_message( char *fmt , ... )
{
   va_list vararg_ptr ;
   va_start( vararg_ptr , fmt ) ;
   output_message( 1 , "*+ WARNING: " , fmt , vararg_ptr ) ;
   va_end( vararg_ptr ) ;
   return ;
}
Esempio n. 19
0
void ININFO_message( char *fmt , ... )
{
   va_list vararg_ptr ;
   va_start( vararg_ptr , fmt ) ;
   output_message( 0 , " + " , fmt , vararg_ptr ) ;
   va_end( vararg_ptr ) ;
   return ;
}
Esempio n. 20
0
static BOOL sane_path(const WCHAR *key)
{
    unsigned int i = strlenW(key);

    if (i < 3 || (key[i - 1] == '\\' && key[i - 2] == '\\'))
    {
        output_message(STRING_INVALID_KEY);
        return FALSE;
    }

    if (key[0] == '\\' && key[1] == '\\' && key[2] != '\\')
    {
        output_message(STRING_NO_REMOTE);
        return FALSE;
    }

    return TRUE;
}
Esempio n. 21
0
void ERROR_exit( char *fmt , ... )
{
   va_list vararg_ptr ;
   va_start( vararg_ptr , fmt ) ;
   output_message( 1 , "** FATAL ERROR: " , fmt , vararg_ptr ) ;
   va_end( vararg_ptr ) ;
   fprintf(stderr,"** Program compile date = %s\n",__DATE__) ;
   exit(1) ;
}
Esempio n. 22
0
void jpeg_error_mgr::error_exit(j_common_ptr cinfo)
{
	/* Always display the message */
	output_message();

	/* Let the memory manager delete any temp files before we die */
	// cinfo->jpeg_destroy();

	throw msg_code; // C++ exception
}
Esempio n. 23
0
/******************************************************************************
 * Removes the registry key with all subkeys. Parses full key name.
 *
 * Parameters:
 * reg_key_name - full name of registry branch to delete. Ignored if is NULL,
 *      empty, points to register key class, does not exist.
 */
void delete_registry_key(WCHAR *reg_key_name)
{
    WCHAR *key_name = NULL;
    HKEY key_class;

    if (!reg_key_name || !reg_key_name[0])
        return;

    if (!parseKeyName(reg_key_name, &key_class, &key_name)) {
        output_message(STRING_INCORRECT_REG_CLASS, reg_key_name);
        exit(1);
    }
    if (!*key_name) {
        output_message(STRING_DELETE_REG_CLASS_FAILED, reg_key_name);
        exit(1);
    }

    RegDeleteTreeW(key_class, key_name);
}
Esempio n. 24
0
void _amqp_debug(const amqp_context_t *context, int level, const char * filename, int line_number, const char *function, const char *format, ...)
{
    if (context->debug.stream && level < context->debug.level)
    {
        va_list args;
        va_start(args, format);
        output_message(context->debug.stream, filename, line_number, "debug", function, format, args);
        va_end(args);
    }
}
Esempio n. 25
0
buffer_t *buffer_load (char *file_name)
{
	char *full_path;
	char line[512];
	FILE *f;
	buffer_t *buf;

	/* use line first to store the full path name */
	full_path = line;

	if (*file_name != '/')
		sprintf (full_path, "%s/.gronda/buffer/%s", 
		                    getenv ("HOME"), file_name);
	else
		strcpy (full_path, file_name);

	f = fopen (full_path, "r");
	if (f == NULL)
	{
		output_message ("Error loading buffer %s", file_name);
		return NULL;
	}

	buf = buffer_create (file_name);

	if (buf == NULL)
	{
		output_message ("Error creating buffer");
		return NULL;
	}

	if (*(buf->str->data))
		string_truncate (buf->str, 0);

	/* line is now used to store data from the file stream */ 
	while (fgets (line, 512, f))
		string_append (buf->str, line);

	fclose (f);

	return buf;
}
Esempio n. 26
0
short good_attack_room(struct Thing *thing)
{
    // Debug code to find incorrect states
    if (!is_hero_thing(thing))
    {
        ERRORLOG("Non hero %s index %d owner %d - reset",thing_model_name(thing),(int)thing->index,(int)thing->owner);
        set_start_state(thing);
        return 0;
    }
    //return _DK_good_attack_room(thing);
    MapSlabCoord base_slb_x,base_slb_y;
    base_slb_x = subtile_slab_fast(thing->mappos.x.stl.num);
    base_slb_y = subtile_slab_fast(thing->mappos.y.stl.num);
    struct Room *room;
    room = slab_room_get(base_slb_x, base_slb_y);
    // If the current tile can be destroyed
    if (room_exists(room) && (room->owner != thing->owner) && !room_cannot_vandalise(room->kind))
    {
        struct CreatureControl *cctrl;
        cctrl = creature_control_get_from_thing(thing);
        if (cctrl->instance_id == CrInst_NULL)
        {
            set_creature_instance(thing, CrInst_ATTACK_ROOM_SLAB, 1, 0, 0);
            MapCoord ev_coord_x,ev_coord_y;
            ev_coord_x = subtile_coord_center(room->central_stl_x);
            ev_coord_y = subtile_coord_center(room->central_stl_y);
            event_create_event_or_update_nearby_existing_event(ev_coord_x, ev_coord_y, EvKind_RoomUnderAttack, room->owner, 0);
            if (is_my_player_number(room->owner))
                output_message(SMsg_EnemyDestroyRooms, MESSAGE_DELAY_FIGHT, true);
        }
        return 1;
    }
    // Otherwise, search around for a tile to destroy
    long m,n;
    m = ACTION_RANDOM(SMALL_AROUND_SLAB_LENGTH);
    for (n=0; n < SMALL_AROUND_SLAB_LENGTH; n++)
    {
        MapSlabCoord slb_x,slb_y;
        slb_x = base_slb_x + (long)small_around[m].delta_x;
        slb_y = base_slb_y + (long)small_around[m].delta_y;
        room = slab_room_get(slb_x, slb_y);
        if (room_exists(room) && (room->owner != thing->owner))
        {
            if (setup_person_move_to_position(thing, slb_x, slb_y, NavRtF_Default))
            {
                thing->continue_state = CrSt_GoodAttackRoom1;
                return 1;
            }
        }
        m = (m+1) % SMALL_AROUND_SLAB_LENGTH;
    }
    set_start_state(thing);
    return 0;
}
Esempio n. 27
0
void jpeg_error_mgr::emit_message(int msg_level)
{
	if (msg_level < 0) 
	{
		/* It's a warning message.  Since corrupt files may generate many warnings,
		* the policy implemented here is to show only the first warning,
		* unless trace_level >= 3.
		*/
		if (num_warnings == 0 || trace_level >= 3)
			output_message();
		/* Always count warnings in num_warnings. */
		num_warnings++;
	} 
	else 
	{
		/* It's a trace message.  Show it if trace_level >= msg_level. */
		if (trace_level >= msg_level)
			output_message();
	}
}
Esempio n. 28
0
/******************************************************************************
 * Converts a hex representation of a DWORD into a DWORD.
 */
static BOOL convertHexToDWord(WCHAR* str, DWORD *dw)
{
    char buf[9];
    char dummy;

    WideCharToMultiByte(CP_ACP, 0, str, -1, buf, 9, NULL, NULL);
    if (lstrlenW(str) > 8 || sscanf(buf, "%x%c", dw, &dummy) != 1) {
        output_message(STRING_INVALID_HEX);
        return FALSE;
    }
    return TRUE;
}
Esempio n. 29
0
/** Displays the current user license
	@return SUCCESS when conditions of use have been satisfied, FAILED when conditions of use have not been satisfied
 **/
STATUS legal_license(void)
{
	int surpress = global_suppress_repeat_messages;
	global_suppress_repeat_messages = 0;
	output_message(
		COPYRIGHT
		"\n"
		"1. Battelle Memorial Institute (hereinafter Battelle) hereby grants\n"
		"   permission to any person or entity lawfully obtaining a copy of\n"
		"   this software and associated documentation files (hereinafter \"the\n"
		"   Software\") to redistribute and use the Software in source and\n"
		"   binary forms, with or without modification.  Such person or entity\n"
		"   may use, copy, modify, merge, publish, distribute, sublicense,\n"
		"   and/or sell copies of the Software, and may permit others to do so,\n"
		"   subject to the following conditions:\n"
		"   - Redistributions of source code must retain the above copyright\n"
		"     notice, this list of conditions and the following disclaimers.\n"
		"   - Redistributions in binary form must reproduce the above copyright\n"
		"     notice, this list of conditions and the following disclaimer in\n"
		"     the documentation and/or other materials provided with the\n"
		"     distribution.\n"
		"   - Other than as used herein, neither the name Battelle Memorial\n"
		"     Institute or Battelle may be used in any form whatsoever without\n"
		"     the express written consent of Battelle.\n"
		"2. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n"
		"   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n"
		"   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n"
		"   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BATTELLE OR\n"
		"   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n"
		"   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n"
		"   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n"
		"   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n"
		"   OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n"
		"   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n"
		"   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
		"3. The Software was produced by Battelle under Contract No.\n"
		"   DE-AC05-76RL01830 with the Department of Energy.  The U.S. Government\n"
		"   is granted for itself and others acting on its behalf a nonexclusive,\n"
		"   paid-up, irrevocable worldwide license in this data to reproduce,\n"
		"   prepare derivative works, distribute copies to the public, perform\n"
		"   publicly and display publicly, and to permit others to do so.  The\n"
		"   specific term of the license can be identified by inquiry made to\n"
		"   Battelle or DOE.  Neither the United States nor the United States\n"
		"   Department of Energy, nor any of their employees, makes any warranty,\n"
		"   express or implied, or assumes any legal liability or responsibility\n"
		"   for the accuracy, completeness or usefulness of any data, apparatus,\n"
		"   product or process disclosed, or represents that its use would not\n"
		"   infringe privately owned rights.\n"
		"\n"
		);
	global_suppress_repeat_messages = surpress;
	return SUCCESS;
}
Esempio n. 30
0
File: mhtest.c Progetto: ella13/nmh
static int
write_content (CT *cts, char *outfile)
{
    CT ct, *ctp;

    for (ctp = cts; *ctp; ctp++) {
	ct = *ctp;
	output_message (ct, outfile);
    }

    flush_errors ();
    return OK;
}