Beispiel #1
0
// When given an IWAD with the '-iwad' parameter,
// attempt to identify it by its name.
void IdentifyIWADByName(char *name)
{
    size_t      i;
    char        *p;

    // Trim down the name to just the filename, ignoring the path.
    p = strrchr(name, DIR_SEPARATOR);
    if (p != NULL)
        name = p + 1;
    gamemission = none;

    for (i = 0; i < arrlen(iwads); ++i)
    {
        char *iwadname = iwads[i].name;

        if (strlen(name) < strlen(iwadname))
            continue;

        // Check if the filename is this IWAD name.
        if (!strcasecmp(name, iwads[i].name))
        {
            gamemission = iwads[i].mission;
            break;
        }
    }
}
Beispiel #2
0
void			join_c(struct s_irc_client *cli,
			       struct s_irc_server *srv,
			       char const *cmd, char const **args)
{
  struct s_irc_chan	*chan;

  if (arrlen(args) < 1)
    cli_reply(cli, srv, "461 %s JOIN :Not enough parameters", cli->nick);
  else if (NULL != (chan = chn_find_or_create(srv->chan_list, args[0])))
    {
      if (0 > chn_join(chan, cli, srv))
	{
	  warn("Cannot let user '%s' join channel '%s'",
	       cli->nick, chan->name);
	  cli_reply(cli, srv, "500 %s :Internal server error", cli->nick);
	}
      else
	{
	  cli_reply(cli, srv, "332 %s %s :%s", cli->nick,
		    chan->name, chan->topic);
	}
    }
  else
    {
      warn("Cannot let user '%s' join channel '%s'", cli->nick, chan->name);
      cli_reply(cli, srv, "500 %s :Internal server error", cli->nick);
    }
}
Beispiel #3
0
static void SuggestOtherVersions(unsigned int offset)
{
    const int *string_list;
    unsigned int i;
    unsigned int v;

    // Check main string table.

    for (i=0; i<arrlen(strings); ++i)
    {
        for (v=0; v<deh_hhe_num_versions; ++v)
        {
            if (strings[i].offsets[v] == offset)
            {
                DEH_SuggestHereticVersion(v);
            }
        }
    }

    // Check unsupported string tables.

    for (v=0; v<deh_hhe_num_versions; ++v)
    {
        string_list = unsupported_strings[v];

        for (i=0; string_list[i] >= 0; ++i)
        {
            if (string_list[i] == offset)
            {
                DEH_SuggestHereticVersion(v);
            }
        }
    }
}
Beispiel #4
0
static void CheckCollectorsEdition(void)
{
    char *install_path;
    char *subpath;
    unsigned int i;

    install_path = GetRegistryString(&collectors_edition_value);

    if (install_path == NULL)
    {
        return;
    }

    for (i=0; i<arrlen(collectors_edition_subdirs); ++i)
    {
        subpath = malloc(strlen(install_path)
                         + strlen(collectors_edition_subdirs[i])
                         + 5);

        sprintf(subpath, "%s\\%s", install_path, collectors_edition_subdirs[i]);

        AddIWADDir(subpath);
    }

    free(install_path);
}
Beispiel #5
0
static void IdentifyIWADByName(char *name)
{
    size_t i;
    char *p;

    // Trim down the name to just the filename, ignoring the path.

    p = strrchr(name, DIR_SEPARATOR);

    if (p != NULL)
    {
        name = p + 1;
    }

    gamemission = none;

    for (i=0; i<arrlen(iwads); ++i)
    {
        // Check if the filename is this IWAD name.

        if (!strcasecmp(name, DEH_String(iwads[i].name)))
        {
            CheckSpecialIWADs(iwads[i].name);
            gamemission = iwads[i].mission;
            break;
        }
    }
}
Beispiel #6
0
static char *GetGameName(char *gamename)
{
    size_t i;
    char *deh_sub;
    
    for (i=0; i<arrlen(banners); ++i)
    {
        // Has the banner been replaced?

        deh_sub = DEH_String(banners[i]);
        
        if (deh_sub != banners[i])
        {
            // Has been replaced
            // We need to expand via printf to include the Doom version 
            // number
            // We also need to cut off spaces to get the basic name

            gamename = Z_Malloc(strlen(deh_sub) + 10, PU_STATIC, 0);
            sprintf(gamename, deh_sub, DOOM_VERSION / 100, DOOM_VERSION % 100);

            while (gamename[0] != '\0' && isspace(gamename[0]))
                strcpy(gamename, gamename+1);

            while (gamename[0] != '\0' && isspace(gamename[strlen(gamename)-1]))
                gamename[strlen(gamename) - 1] = '\0';
            
            return gamename;
        }
    }

    return gamename;
}
Beispiel #7
0
// Translates the SDL key to a value of the type found in doomkeys.h
static int TranslateKey(SDL_Keysym *sym)
{
    int scancode = sym->scancode;

    switch (scancode)
    {
        case SDL_SCANCODE_LCTRL:
        case SDL_SCANCODE_RCTRL:
            return KEY_RCTRL;

        case SDL_SCANCODE_LSHIFT:
        case SDL_SCANCODE_RSHIFT:
            return KEY_RSHIFT;

        case SDL_SCANCODE_LALT:
            return KEY_LALT;

        case SDL_SCANCODE_RALT:
            return KEY_RALT;

        default:
            if (scancode >= 0 && scancode < arrlen(scancode_translate_table))
            {
                return scancode_translate_table[scancode];
            }
            else
            {
                return 0;
            }
    }
}
Beispiel #8
0
static GameMission_t IdentifyIWADByName(char *name, int mask)
{
    size_t i;
    GameMission_t mission;
    char *p;

    p = strrchr(name, DIR_SEPARATOR);

    if (p != NULL)
    {
        name = p + 1;
    }

    mission = none;

    for (i=0; i<arrlen(iwads); ++i)
    {
        // Check if the filename is this IWAD name.

        // Only use supported missions:

        if (((1 << iwads[i].mission) & mask) == 0)
            continue;

        // Check if it ends in this IWAD name.

        if (!strcasecmp(name, iwads[i].name))
        {
            mission = iwads[i].mission;
            break;
        }
    }

    return mission;
}
// Rearrange joystick button configuration to be in "canonical" form:
// each joyb* variable should have a value equal to its index in
// all_joystick_buttons[] above.
static void CanonicalizeButtons(void)
{
    int new_mapping[NUM_VIRTUAL_BUTTONS];
    int vbutton;
    int i;

    for (i = 0; i < arrlen(all_joystick_buttons); ++i)
    {
        vbutton = *all_joystick_buttons[i];

        // Don't remap the speed key if it's bound to "always run".
        // Also preserve "unbound" variables.
        if ((all_joystick_buttons[i] == &joybspeed && vbutton >= 20)
         || vbutton < 0)
        {
            new_mapping[i] = i;
        }
        else
        {
            new_mapping[i] = PhysicalForVirtualButton(vbutton);
            *all_joystick_buttons[i] = i;
        }
    }

    for (i = 0; i < NUM_VIRTUAL_BUTTONS; ++i)
    {
        joystick_physical_buttons[i] = new_mapping[i];
    }
}
Beispiel #10
0
wad_file_t *W_OpenFile(char *path)
{
    wad_file_t *result;
    int i;

    //!
    // Use the OS's virtual memory subsystem to map WAD files
    // directly into memory.
    //

    if (!M_CheckParm("-mmap"))
    {
        return stdc_wad_file.OpenFile(path);
    }

    // Try all classes in order until we find one that works

    result = NULL;

    for (i=0; i<arrlen(wad_file_classes); ++i)
    {
        result = wad_file_classes[i]->OpenFile(path);

        if (result != NULL)
        {
            break;
        }
    }

    return result;
}
Beispiel #11
0
static void CheckUninstallStrings(void)
{
    unsigned int i;

    for (i=0; i<arrlen(uninstall_values); ++i)
    {
        char *val;
        char *path;
        char *unstr;

        val = GetRegistryString(&uninstall_values[i]);

        if (val == NULL)
        {
            continue;
        }

        unstr = strstr(val, UNINSTALLER_STRING);

        if (unstr == NULL)
        {
            free(val);
        }
        else
        {
            path = unstr + strlen(UNINSTALLER_STRING);

            AddIWADDir(path);
        }
    }
}
Beispiel #12
0
void map_display (void) {
  int i;
  for (i = 0; i < arrlen (chunks); ++i) {
    glColor3f (0, 0, 1);
    ugl_rprism (CHUNK_DX*i, 0, 0, CHUNK_DX, CHUNK_DY, CHUNK_DZ);
    chunk_display (chunks[i], i * CHUNK_DX);
  }
}
Beispiel #13
0
static void OpenGameSelectDialog(GameSelectCallback callback)
{
    mission_config_t *mission = NULL;
    txt_window_t *window;
    const iwad_t **iwads;
    int num_games;
    int i;

    window = TXT_NewWindow("Select game");

    TXT_AddWidget(window, TXT_NewLabel("Select a game to configure:\n"));
    num_games = 0;

    // Add a button for each game.

    for (i=0; i<arrlen(mission_configs); ++i)
    {
        // Do we have any IWADs for this game installed?
        // If so, add a button.

        iwads = D_FindAllIWADs(mission_configs[i].mask);

        if (iwads[0] != NULL)
        {
            mission = &mission_configs[i];
            TXT_AddWidget(window, TXT_NewButton2(mission_configs[i].label,
                                                 GameSelected,
                                                 &mission_configs[i]));
            ++num_games;
        }

        free(iwads);
    }

    TXT_AddWidget(window, TXT_NewStrut(0, 1));

    // No IWADs found at all?  Fall back to doom, then.

    if (num_games == 0)
    {
        TXT_CloseWindow(window);
        SetMission(DEFAULT_MISSION);
        callback();
        return;
    }

    // Only one game? Use that game, and don't bother with a dialog.

    if (num_games == 1)
    {
        TXT_CloseWindow(window);
        SetMission(mission);
        callback();
        return;
    }

    game_selected_callback = callback;
}
Beispiel #14
0
boolean F_CastResponder (event_t* ev)
{
    boolean xdeath = false;

    if (ev->type != ev_keydown)
	return false;

    // [crispy] make monsters turnable in cast ...
    if (ev->data1 == key_left)
    {
	if (++castangle > 7)
	    castangle = 0;
	return false;
    }
    else
    if (ev->data1 == key_right)
    {
	if (--castangle < 0)
	    castangle = 7;
	return false;
    }
    else
    // [crispy] ... and allow to skip through them ..
    if (ev->data1 == key_strafeleft || ev->data1 == key_alt_strafeleft)
    {
	castskip = castnum ? -1 : arrlen(castorder)-2;
	return false;
    }
    else
    if (ev->data1 == key_straferight || ev->data1 == key_alt_straferight)
    {
	castskip = +1;
	return false;
    }
    // [crispy] ... and finally turn them into gibbs
    if (ev->data1 == key_speed)
	xdeath = true;
		
    if (castdeath)
	return true;			// already in dying frames
		
    // go into death frame
    castdeath = true;
    if (xdeath && mobjinfo[castorder[castnum].type].xdeathstate)
	caststate = &states[mobjinfo[castorder[castnum].type].xdeathstate];
    else
    caststate = &states[mobjinfo[castorder[castnum].type].deathstate];
    casttics = caststate->tics;
    castframes = 0;
    castattacking = false;
    if (xdeath && mobjinfo[castorder[castnum].type].xdeathstate)
        S_StartSound (NULL, sfx_slop);
    else
    if (mobjinfo[castorder[castnum].type].deathsound)
	S_StartSound (NULL, mobjinfo[castorder[castnum].type].deathsound);
	
    return true;
}
Beispiel #15
0
void map_gen (void) {
  int i, j, k, l;
  terrain_init ();
  for (l = 0; l < arrlen (chunks); ++l)
    for (i = 0; i < CHUNK_DX; ++i)
      for (j = 0; j < CHUNK_DY; ++j)
        for (k = 0; k < CHUNK_DZ; ++k)
          chunks[l][i][j][k] = rng_f () < 0.05;
  terrain_del ();
}
Beispiel #16
0
//
// F_StartFinale
//
void F_StartFinale (void)
{
    size_t i;

    gameaction = ga_nothing;
    gamestate = GS_FINALE;
    viewactive = false;
    automapactive = false;

    if (logical_gamemission == doom)
    {
        S_ChangeMusic(mus_victor, true);
    }
    else
    {
        S_ChangeMusic(mus_read_m, true);
    }

    // Find the right screen and set the text and background

    for (i=0; i<arrlen(textscreens); ++i)
    {
        textscreen_t *screen = &textscreens[i];

        // Hack for Chex Quest

        if (gameversion == exe_chex && screen->mission == doom)
        {
            screen->level = 5;
        }

        // [crispy] Hack for Master Levels MAP21: Bad Dream
        if (gamemission == pack_master && screen->mission == pack_master && gamemap == 21)
        {
            screen->level = 21;
        }

        if (logical_gamemission == screen->mission
         && (logical_gamemission != doom || gameepisode == screen->episode)
         && gamemap == screen->level)
        {
            finaletext = screen->text;
            finaleflat = screen->background;
        }
    }

    // Do dehacked substitutions of strings
  
    finaletext = DEH_String(finaletext);
    finaleflat = DEH_String(finaleflat);
    
    finalestage = F_STAGE_TEXT;
    finalecount = 0;
	
}
Beispiel #17
0
static deh_cheat_t *FindCheatByName(char *name)
{
    size_t i;
    
    for (i=0; i<arrlen(allcheats); ++i)
    {
        if (!strcasecmp(allcheats[i].name, name))
            return &allcheats[i];
    }

    return NULL;
}
Beispiel #18
0
MALLOC static int64_t*
arr_to_i64v(const json_value* v)
{
  assert(v->type == json_array);
  const size_t len = arrlen(v);
  int64_t* values = calloc(len, sizeof(int64_t));
  for(size_t i=0; i < len; ++i) {
    const json_value* integer = objderef(js_by_idx(v, i));
    assert(integer->type == json_integer);
    values[i] = js_int(integer);
  }
  return values;
}
Beispiel #19
0
MALLOC static double*
arr_to_lfv(const json_value* v)
{
  assert(v->type == json_array);
  const size_t len = arrlen(v);
  double* values = calloc(len, sizeof(double));
  for(size_t i=0; i < len; ++i) {
    const json_value* dbl = objderef(js_by_idx(v, i));
    assert(dbl->type == json_double);
    values[i] = js_double(dbl);
  }
  return values;
}
Beispiel #20
0
char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode)
{
    int i;

    for (i = 0; i < arrlen(iwads); ++i)
    {
        if (iwads[i].mission == mission && iwads[i].mode == mode)
        {
            return iwads[i].name;
        }
    }

    return "unknown.wad";
}
Beispiel #21
0
static mission_config_t *GetMissionForName(char *name)
{
    int i;

    for (i=0; i<arrlen(mission_configs); ++i)
    {
        if (!strcmp(mission_configs[i].name, name))
        {
            return &mission_configs[i];
        }
    }

    return NULL;
}
Beispiel #22
0
boolean D_ValidGameMode(GameMission_t mission, GameMode_t mode)
{
    int i;

    for (i=0; i<arrlen(valid_modes); ++i)
    {
        if (valid_modes[i].mode == mode && valid_modes[i].mission == mission)
        {
            return true;
        }
    }

    return false;
}
Beispiel #23
0
char *D_SuggestGameName(GameMission_t mission, GameMode_t mode)
{
    int i;

    for (i = 0; i < arrlen(iwads); ++i)
    {
        if (iwads[i].mission == mission && iwads[i].mode == mode)
        {
            return iwads[i].description;
        }
    }

    return "Unknown game?";
}
static iwad_t *GetIWADForDescription(char *description)
{
    unsigned int i;

    for (i=0; i<arrlen(iwads); ++i)
    {
        if (!strcmp(iwads[i].description, description))
        {
            return &iwads[i];
        }
    }

    return NULL;
}
// Get the virtual button number for the given variable, ie. the
// variable's index in all_joystick_buttons[].
static int VirtualButtonForVariable(int *variable)
{
    int i;

    for (i = 0; i < arrlen(all_joystick_buttons); ++i)
    {
        if (variable == all_joystick_buttons[i])
        {
            return i;
        }
    }

    I_Error("Couldn't find virtual button");
    return -1;
}
// Check all existing buttons and clear any using the specified physical
// button.
static void ClearVariablesUsingButton(int physbutton)
{
    int vbutton;
    int i;

    for (i = 0; i < arrlen(all_joystick_buttons); ++i)
    {
        vbutton = *all_joystick_buttons[i];

        if (vbutton >= 0 && physbutton == PhysicalForVirtualButton(vbutton))
        {
            *all_joystick_buttons[i] = -1;
        }
    }
}
Beispiel #27
0
static void SuggestOtherVersions(unsigned int offset)
{
    unsigned int i, v;

    for (i=0; i<arrlen(action_pointers); ++i)
    {
        for (v=0; v<deh_hhe_num_versions; ++v)
        {
            if (action_pointers[i].offsets[v] == offset)
            {
                DEH_SuggestHereticVersion(v);
            }
        }
    }
}
Beispiel #28
0
static boolean GetStringByOffset(unsigned int offset, char **result)
{
    int i;

    for (i=0; i<arrlen(strings); ++i)
    {
        if (strings[i].offsets[deh_hhe_version] == offset)
        {
            *result = strings[i].string;
            return true;
        }
    }

    return false;
}
Beispiel #29
0
static const known_joystick_t *GetJoystickType(int index)
{
    SDL_Joystick *joystick;
    const char *name;
    int axes, buttons, hats;
    int i;

    joystick = all_joysticks[index];
    name = SDL_JoystickName(index);
    axes = SDL_JoystickNumAxes(joystick);
    buttons = SDL_JoystickNumButtons(joystick);
    hats = SDL_JoystickNumHats(joystick);

    for (i = 0; i < arrlen(known_joysticks); ++i)
    {
        // Check for a name match. If the name ends in '*', this means
        // ignore the rest.
        if (M_StringEndsWith(known_joysticks[i].name, "*"))
        {
            if (strncmp(known_joysticks[i].name, name,
                        strlen(known_joysticks[i].name) - 1) != 0)
            {
                continue;
            }
        }
        else
        {
            if (strcmp(known_joysticks[i].name, name) != 0)
            {
                continue;
            }
        }

        if (known_joysticks[i].axes == axes
         && known_joysticks[i].buttons == buttons
         && known_joysticks[i].hats == hats)
        {
            return &known_joysticks[i];
        }
    }

    printf("Unknown joystick '%s' with %i axes, %i buttons, %i hats\n",
           name, axes, buttons, hats);
    printf("Please consider sending in details about your gamepad!\n");

    return NULL;
}
Beispiel #30
0
static void MouseSetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable))
{
    TXT_CAST_ARG(int, variable);
    unsigned int i;

    // Check if the same mouse button is used for a different action
    // If so, set the other action(s) to -1 (unset)

    for (i=0; i<arrlen(all_mouse_buttons); ++i)
    {
        if (*all_mouse_buttons[i] == *variable
         && all_mouse_buttons[i] != variable)
        {
            *all_mouse_buttons[i] = -1;
        }
    }
}