Subversion Repositories eduke32

Rev

Rev 4839 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4839 Rev 4895
Line 571... Line 571...
571
    return i;
571
    return i;
572
}
572
}
573
573
574
int32_t __fastcall Gv_GetVar(int32_t id, int32_t iActor, int32_t iPlayer)
574
int32_t __fastcall Gv_GetVar(int32_t id, int32_t iActor, int32_t iPlayer)
575
{
575
{
576
    int negateResult;
-
 
577
-
 
578
    if (id == g_iThisActorID)
576
    if (id == g_iThisActorID)
579
        return iActor;
577
        return iActor;
580
578
581
    if (id == MAXGAMEVARS)
579
    if (id == MAXGAMEVARS)
582
        return(*insptr++);
580
        return *insptr++;
583
581
584
    negateResult = id&(MAXGAMEVARS<<1);
582
    int negateResult = !!(id & (MAXGAMEVARS << 1));
585
583
586
    if (EDUKE32_PREDICT_FALSE(id >= g_gameVarCount && !negateResult))
584
    if (EDUKE32_PREDICT_FALSE(id >= g_gameVarCount && !negateResult))
587
        goto nastyhacks;
585
        goto nastyhacks;
588
586
589
    id &= (MAXGAMEVARS-1);
587
    id &= (MAXGAMEVARS - 1);
590
588
591
    switch (aGameVars[id].dwFlags &
589
    int rv, f;
592
        (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK))
590
    f = aGameVars[id].dwFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK);
-
 
591
-
 
592
    if (!f) rv = (aGameVars[id].val.lValue ^ -negateResult) + negateResult;
-
 
593
    else if (f == GAMEVAR_PERPLAYER)
593
    {
594
    {
594
    default:
-
 
595
        return ((aGameVars[id].val.lValue ^ -negateResult) + negateResult);
-
 
596
    case GAMEVAR_PERPLAYER:
-
 
597
        if (EDUKE32_PREDICT_FALSE((unsigned) iPlayer >= MAXPLAYERS)) goto bad_id;
595
        if (EDUKE32_PREDICT_FALSE((unsigned) iPlayer >= MAXPLAYERS)) goto bad_id;
598
        return ((aGameVars[id].val.plValues[iPlayer] ^ -negateResult) + negateResult);
596
        rv = (aGameVars[id].val.plValues[iPlayer] ^ -negateResult) + negateResult;
-
 
597
    }
599
    case GAMEVAR_PERACTOR:
598
    else if (f == GAMEVAR_PERACTOR)
-
 
599
    {
600
        if (EDUKE32_PREDICT_FALSE((unsigned) iActor >= MAXSPRITES)) goto bad_id;
600
        if (EDUKE32_PREDICT_FALSE((unsigned) iActor >= MAXSPRITES)) goto bad_id;
601
        return ((aGameVars[id].val.plValues[iActor] ^ -negateResult) + negateResult);
601
        rv = (aGameVars[id].val.plValues[iActor] ^ -negateResult) + negateResult;
602
    case GAMEVAR_INTPTR:
-
 
603
        return (((*((int32_t *) aGameVars[id].val.lValue)) ^ -negateResult) + negateResult);
-
 
604
    case GAMEVAR_SHORTPTR:
-
 
605
        return (((*((int16_t *) aGameVars[id].val.lValue)) ^ -negateResult) + negateResult);
-
 
606
    case GAMEVAR_CHARPTR:
-
 
607
        return (((*((char *) aGameVars[id].val.lValue)) ^ -negateResult) + negateResult);
-
 
608
    }
602
    }
-
 
603
    else switch (f)
-
 
604
    {
-
 
605
        case GAMEVAR_INTPTR: rv = ((*((int32_t *)aGameVars[id].val.lValue)) ^ -negateResult) + negateResult; break;
-
 
606
        case GAMEVAR_SHORTPTR: rv = ((*((int16_t *)aGameVars[id].val.lValue)) ^ -negateResult) + negateResult; break;
-
 
607
        case GAMEVAR_CHARPTR: rv = ((*((char *)aGameVars[id].val.lValue)) ^ -negateResult) + negateResult; break;
-
 
608
    }
-
 
609
-
 
610
    return rv;
609
611
610
nastyhacks:
612
nastyhacks:
611
    if (id&(MAXGAMEVARS<<2)) // array
613
    if (id & (MAXGAMEVARS << 2))  // array
612
    {
614
    {
613
        int32_t index=Gv_GetVar(*insptr++, iActor, iPlayer);
-
 
614
-
 
615
        id &= (MAXGAMEVARS-1);// ~((MAXGAMEVARS<<2)|(MAXGAMEVARS<<1));
615
        id &= (MAXGAMEVARS - 1);  // ~((MAXGAMEVARS<<2)|(MAXGAMEVARS<<1));
616
616
-
 
617
        int32_t index = Gv_GetVar(*insptr++, iActor, iPlayer);
-
 
618
617
        if (EDUKE32_PREDICT_FALSE((unsigned) index >= (unsigned) aGameArrays[id].size))
619
        if (EDUKE32_PREDICT_FALSE((unsigned)index >= (unsigned)aGameArrays[id].size))
618
        {
620
        {
619
            iActor = index;
621
            iActor = index;
620
            goto badindex;
622
            goto badindex;
621
        }
623
        }
Line 717... Line 719...
717
719
718
void __fastcall Gv_SetVar(int32_t id, int32_t lValue, int32_t iActor, int32_t iPlayer)
720
void __fastcall Gv_SetVar(int32_t id, int32_t lValue, int32_t iActor, int32_t iPlayer)
719
{
721
{
720
    if (EDUKE32_PREDICT_FALSE((unsigned)id >= (unsigned)g_gameVarCount)) goto badvarid;
722
    if (EDUKE32_PREDICT_FALSE((unsigned)id >= (unsigned)g_gameVarCount)) goto badvarid;
721
723
722
    //Bsprintf(g_szBuf,"SGVI: %d (\"%s\") to %d for %d %d",id,aGameVars[id].szLabel,lValue,iActor,iPlayer);
-
 
723
    //AddLog(g_szBuf);
724
    int f;
-
 
725
    f = aGameVars[id].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK);
724
726
725
    switch (aGameVars[id].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK))
727
    if (!f) aGameVars[id].val.lValue=lValue;
-
 
728
    else if (f == GAMEVAR_PERPLAYER)
726
    {
729
    {
727
    default:
-
 
728
        aGameVars[id].val.lValue=lValue;
-
 
729
        return;
-
 
730
    case GAMEVAR_PERPLAYER:
-
 
731
        if (EDUKE32_PREDICT_FALSE((unsigned)iPlayer > MAXPLAYERS-1)) goto badindex;
730
        if (EDUKE32_PREDICT_FALSE((unsigned) iPlayer > MAXPLAYERS-1)) goto badindex;
732
        // for the current player
731
        // for the current player
733
        aGameVars[id].val.plValues[iPlayer]=lValue;
732
        aGameVars[id].val.plValues[iPlayer]=lValue;
734
        return;
733
    }
735
    case GAMEVAR_PERACTOR:
734
    else if (f == GAMEVAR_PERACTOR)
-
 
735
    {
736
        if (EDUKE32_PREDICT_FALSE((unsigned)iActor > MAXSPRITES-1)) goto badindex;
736
        if (EDUKE32_PREDICT_FALSE((unsigned) iActor > MAXSPRITES-1)) goto badindex;
737
        aGameVars[id].val.plValues[iActor]=lValue;
737
        aGameVars[id].val.plValues[iActor]=lValue;
738
        return;
-
 
739
    case GAMEVAR_INTPTR:
-
 
740
        *((int32_t *)aGameVars[id].val.lValue)=(int32_t)lValue;
-
 
741
        return;
-
 
742
    case GAMEVAR_SHORTPTR:
-
 
743
        *((int16_t *)aGameVars[id].val.lValue)=(int16_t)lValue;
-
 
744
        return;
-
 
745
    case GAMEVAR_CHARPTR:
-
 
746
        *((uint8_t *)aGameVars[id].val.lValue)=(uint8_t)lValue;
-
 
747
        return;
-
 
748
    }
738
    }
-
 
739
    else
-
 
740
    {
-
 
741
        switch (f)
-
 
742
        {
-
 
743
            case GAMEVAR_INTPTR: *((int32_t *)aGameVars[id].val.lValue) = (int32_t)lValue; break;
-
 
744
            case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[id].val.lValue) = (int16_t)lValue; break;
-
 
745
            case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[id].val.lValue) = (uint8_t)lValue; break;
-
 
746
        }
-
 
747
    }
-
 
748
    return;
749
749
750
badvarid:
750
badvarid:
751
    CON_ERRPRINTF("Gv_SetVar(): invalid gamevar (%d) from sprite %d (%d), player %d\n",
751
    CON_ERRPRINTF("Gv_SetVar(): invalid gamevar (%d) from sprite %d (%d), player %d\n",
752
                  id,vm.g_i,TrackerCast(sprite[vm.g_i].picnum),vm.g_p);
752
                  id,vm.g_i,TrackerCast(sprite[vm.g_i].picnum),vm.g_p);
753
    return;
753
    return;
754
754
755
badindex:
755
badindex:
756
    CON_ERRPRINTF("Gv_SetVar(): invalid index (%d) for gamevar %s from sprite %d, player %d\n",
756
    CON_ERRPRINTF("Gv_SetVar(): invalid index (%d) for gamevar %s from sprite %d, player %d\n",
757
               aGameVars[id].dwFlags & GAMEVAR_PERACTOR ? iActor : iPlayer,
757
               aGameVars[id].dwFlags & GAMEVAR_PERACTOR ? iActor : iPlayer,
758
               aGameVars[id].szLabel,vm.g_i,vm.g_p);
758
               aGameVars[id].szLabel,vm.g_i,vm.g_p);
759
    return;
-
 
760
}
759
}
761
760
762
enum {
761
enum {
763
    GVX_BADVARID = 0,
762
    GVX_BADVARID = 0,
764
    GVX_BADPLAYER,
763
    GVX_BADPLAYER,
Line 766... Line 765...
766
    GVX_BADSECTOR,
765
    GVX_BADSECTOR,
767
    GVX_BADWALL,
766
    GVX_BADWALL,
768
    GVX_BADINDEX,
767
    GVX_BADINDEX,
769
};
768
};
770
769
-
 
770
static const char *gvxerrs[] = {
771
static const char *gvxerrs [] ={ "Gv_GetVarX(): invalid gamevar ID",
771
    "Gv_GetVarX(): invalid gamevar ID",
772
"Gv_GetVarX(): invalid player ID",
772
    "Gv_GetVarX(): invalid player ID",
773
"Gv_GetVarX(): invalid sprite ID",
773
    "Gv_GetVarX(): invalid sprite ID",
774
"Gv_GetVarX(): invalid sector ID",
774
    "Gv_GetVarX(): invalid sector ID",
775
"Gv_GetVarX(): invalid wall ID",
775
    "Gv_GetVarX(): invalid wall ID",
776
"Gv_GetVarX(): invalid array index",
776
    "Gv_GetVarX(): invalid array index",
777
};
777
};
778
778
779
int32_t __fastcall Gv_GetVarX(int32_t id)
779
int32_t __fastcall Gv_GetVarX(int32_t id)
780
{
780
{
781
    intptr_t negateResult = id&(MAXGAMEVARS<<1);
-
 
782
-
 
783
    if (id == g_iThisActorID)
781
    if (id == g_iThisActorID)
784
        return vm.g_i;
782
        return vm.g_i;
785
783
786
    if (id == MAXGAMEVARS)
784
    if (id == MAXGAMEVARS)
787
        return(*insptr++);
785
        return *insptr++;
-
 
786
-
 
787
    int negateResult = !!(id & (MAXGAMEVARS << 1)), rv = -1, f;
788
788
789
    if (EDUKE32_PREDICT_FALSE(id >= g_gameVarCount && negateResult == 0))
789
    if (EDUKE32_PREDICT_FALSE(id >= g_gameVarCount && negateResult == 0))
790
        goto nastyhacks;
790
        goto nastyhacks;
791
791
792
    id &= MAXGAMEVARS-1;
792
    id &= MAXGAMEVARS-1;
793
793
794
    switch (aGameVars[id].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK))
794
    f = aGameVars[id].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK);
-
 
795
-
 
796
    if (!f) rv = (aGameVars[id].val.lValue ^ -negateResult) + negateResult;
-
 
797
    else if (f == GAMEVAR_PERPLAYER)
795
    {
798
    {
796
    default:
-
 
797
        return ((aGameVars[id].val.lValue ^ -negateResult) + negateResult);
-
 
798
    case GAMEVAR_PERPLAYER:
-
 
799
        if (EDUKE32_PREDICT_FALSE((unsigned) vm.g_p >= MAXPLAYERS))
799
        if (EDUKE32_PREDICT_FALSE((unsigned) vm.g_p >= MAXPLAYERS))
800
        {
-
 
801
            id = vm.g_p;
800
            goto perr;
802
            CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], id);
801
        rv = (aGameVars[id].val.plValues[vm.g_p] ^ -negateResult) + negateResult;
803
            return -1;
-
 
804
        }
802
    }
805
        return ((aGameVars[id].val.plValues[vm.g_p] ^ -negateResult) + negateResult);
-
 
806
    case GAMEVAR_PERACTOR:
803
    else if (f == GAMEVAR_PERACTOR)
807
        return ((aGameVars[id].val.plValues[vm.g_i] ^ -negateResult) + negateResult);
804
        rv = (aGameVars[id].val.plValues[vm.g_i] ^ -negateResult) + negateResult;
-
 
805
    else switch (f)
-
 
806
    {
808
    case GAMEVAR_INTPTR:
807
        case GAMEVAR_INTPTR:
809
        return (((*((int32_t *) aGameVars[id].val.lValue)) ^ -negateResult) + negateResult);
808
            rv = ((*((int32_t *) aGameVars[id].val.lValue)) ^ -negateResult) + negateResult; break;
810
    case GAMEVAR_SHORTPTR:
809
        case GAMEVAR_SHORTPTR:
811
        return (((*((int16_t *) aGameVars[id].val.lValue)) ^ -negateResult) + negateResult);
810
            rv = ((*((int16_t *) aGameVars[id].val.lValue)) ^ -negateResult) + negateResult; break;
812
    case GAMEVAR_CHARPTR:
811
        case GAMEVAR_CHARPTR:
813
        return (((*((uint8_t *) aGameVars[id].val.lValue)) ^ -negateResult) + negateResult);
812
            rv = ((*((uint8_t *) aGameVars[id].val.lValue)) ^ -negateResult) + negateResult; break;
814
    }
813
    }
815
814
-
 
815
    return rv;
-
 
816
-
 
817
perr:
-
 
818
    id = vm.g_p;
-
 
819
    CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], id);
-
 
820
    return -1;
-
 
821
816
nastyhacks:
822
nastyhacks:
817
    if (id&(MAXGAMEVARS<<2)) // array
823
    if (id & (MAXGAMEVARS << 2))  // array
818
    {
824
    {
819
        int32_t index=Gv_GetVarX(*insptr++);
825
        int32_t index = Gv_GetVarX(*insptr++);
820
        int32_t siz;
-
 
821
826
822
        id &= (MAXGAMEVARS-1);// ~((MAXGAMEVARS<<2)|(MAXGAMEVARS<<1));
827
        id &= (MAXGAMEVARS - 1);  // ~((MAXGAMEVARS<<2)|(MAXGAMEVARS<<1));
823
828
824
        siz = (aGameArrays[id].dwFlags & GAMEARRAY_VARSIZE) ? Gv_GetVarX(aGameArrays[id].size) : aGameArrays[id].size;
829
        int siz = (aGameArrays[id].dwFlags & GAMEARRAY_VARSIZE) ? Gv_GetVarX(aGameArrays[id].size) : aGameArrays[id].size;
825
830
826
        if (EDUKE32_PREDICT_FALSE(index < 0 || index >= siz))
831
        if (EDUKE32_PREDICT_FALSE((unsigned) index >= (unsigned) siz))
827
        {
832
        {
828
            negateResult = index;
833
            negateResult = index;
829
            CON_ERRPRINTF("%s %s[%d]\n", gvxerrs[GVX_BADINDEX], aGameArrays[id].szLabel, index);
834
            CON_ERRPRINTF("%s %s[%d]\n", gvxerrs[GVX_BADINDEX], aGameArrays[id].szLabel, index);
830
            return -1;
835
            return -1;
831
        }
836
        }
832
837
833
        switch (aGameArrays[id].dwFlags & GAMEARRAY_TYPE_MASK)
838
        switch (aGameArrays[id].dwFlags & GAMEARRAY_TYPE_MASK)
834
        {
839
        {
835
        case 0:
-
 
836
            return ((aGameArrays[id].plValues)[index] ^ -negateResult) + negateResult;
840
            case 0: return ((aGameArrays[id].plValues)[index] ^ -negateResult) + negateResult;
837
        case GAMEARRAY_OFINT:
-
 
838
            return (((int32_t *) aGameArrays[id].plValues)[index] ^ -negateResult) + negateResult;
841
            case GAMEARRAY_OFINT: return (((int32_t *) aGameArrays[id].plValues)[index] ^ -negateResult) + negateResult;
839
        case GAMEARRAY_OFSHORT:
842
            case GAMEARRAY_OFSHORT:
840
            return (((int16_t *) aGameArrays[id].plValues)[index] ^ -negateResult) + negateResult;
843
                return (((int16_t *) aGameArrays[id].plValues)[index] ^ -negateResult) + negateResult;
841
        case GAMEARRAY_OFCHAR:
-
 
842
            return (((uint8_t *) aGameArrays[id].plValues)[index] ^ -negateResult) + negateResult;
844
            case GAMEARRAY_OFCHAR: return (((uint8_t *) aGameArrays[id].plValues)[index] ^ -negateResult) + negateResult;
843
        default:
-
 
844
            EDUKE32_UNREACHABLE_SECTION(return -1);
845
            default: EDUKE32_UNREACHABLE_SECTION(return -1);
845
        }
846
        }
846
    }
847
    }
847
848
848
    if (id&(MAXGAMEVARS<<3)) // struct shortcut vars
849
    if (id&(MAXGAMEVARS<<3)) // struct shortcut vars
849
    {
850
    {
Line 914... Line 915...
914
    EDUKE32_UNREACHABLE_SECTION(return -1);
915
    EDUKE32_UNREACHABLE_SECTION(return -1);
915
}
916
}
916
917
917
void __fastcall Gv_SetVarX(int32_t id, int32_t lValue)
918
void __fastcall Gv_SetVarX(int32_t id, int32_t lValue)
918
{
919
{
919
    switch (aGameVars[id].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK))
920
    int f = aGameVars[id].dwFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK);
-
 
921
-
 
922
    if (!f) aGameVars[id].val.lValue = lValue;
-
 
923
    else if (f == GAMEVAR_PERPLAYER)
920
    {
924
    {
921
    default:
-
 
922
        aGameVars[id].val.lValue=lValue;
-
 
923
        return;
-
 
924
    case GAMEVAR_PERPLAYER:
-
 
925
        if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_p > MAXPLAYERS-1)) goto badindex;
925
        if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_p >= MAXPLAYERS)) goto badindex;
926
        aGameVars[id].val.plValues[vm.g_p]=lValue;
926
        aGameVars[id].val.plValues[vm.g_p] = lValue;
927
        return;
927
    }
928
    case GAMEVAR_PERACTOR:
928
    else if (f == GAMEVAR_PERACTOR)
-
 
929
    {
929
        if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_i > MAXSPRITES-1)) goto badindex;
930
        if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_i >= MAXSPRITES)) goto badindex;
930
        aGameVars[id].val.plValues[vm.g_i]=lValue;
931
        aGameVars[id].val.plValues[vm.g_i] = lValue;
931
        return;
-
 
932
    case GAMEVAR_INTPTR:
-
 
933
        *((int32_t *)aGameVars[id].val.lValue)=(int32_t)lValue;
-
 
934
        return;
-
 
935
    case GAMEVAR_SHORTPTR:
-
 
936
        *((int16_t *)aGameVars[id].val.lValue)=(int16_t)lValue;
-
 
937
        return;
-
 
938
    case GAMEVAR_CHARPTR:
-
 
939
        *((uint8_t *)aGameVars[id].val.lValue)=(uint8_t)lValue;
-
 
940
        return;
-
 
941
    }
932
    }
-
 
933
    else
-
 
934
    {
-
 
935
        switch (f)
-
 
936
        {
-
 
937
            case GAMEVAR_INTPTR: *((int32_t *)aGameVars[id].val.lValue) = (int32_t)lValue; break;
-
 
938
            case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[id].val.lValue) = (int16_t)lValue; break;
-
 
939
            case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[id].val.lValue) = (uint8_t)lValue; break;
-
 
940
        }
-
 
941
    }
-
 
942
-
 
943
    return;
942
944
943
badindex:
945
badindex:
944
    CON_ERRPRINTF("Gv_SetVar(): invalid index (%d) for gamevar %s\n",
946
    CON_ERRPRINTF("Gv_SetVar(): invalid index (%d) for gamevar %s\n",
945
               aGameVars[id].dwFlags & GAMEVAR_PERACTOR ? vm.g_i : vm.g_p,
947
               aGameVars[id].dwFlags & GAMEVAR_PERACTOR ? vm.g_i : vm.g_p,
946
               aGameVars[id].szLabel);
948
               aGameVars[id].szLabel);
947
    return;
-
 
948
}
949
}
949
950
950
int32_t Gv_GetVarByLabel(const char *szGameLabel, int32_t lDefault, int32_t iActor, int32_t iPlayer)
951
int32_t Gv_GetVarByLabel(const char *szGameLabel, int32_t lDefault, int32_t iActor, int32_t iPlayer)
951
{
952
{
952
    int32_t i = hash_find(&h_gamevars,szGameLabel);
953
    int32_t i = hash_find(&h_gamevars,szGameLabel);
Line 970... Line 971...
970
971
971
    return &(aGameVars[i].val.lValue);
972
    return &(aGameVars[i].val.lValue);
972
}
973
}
973
#endif  // !defined LUNATIC
974
#endif  // !defined LUNATIC
974
975
975
static void G_InitProjectileData(void)
-
 
976
{
-
 
977
    int32_t i;
-
 
978
    for (i=0; i<=MAXTILES-1; i++)
-
 
979
        Bmemcpy(&ProjectileData[i], &g_tile[i].defproj, sizeof(projectile_t));
-
 
980
}
-
 
981
-
 
982
void Gv_ResetSystemDefaults(void)
976
void Gv_ResetSystemDefaults(void)
983
{
977
{
984
    // call many times...
978
    // call many times...
985
#if !defined LUNATIC
979
#if !defined LUNATIC
986
    int32_t i;
980
    int32_t i;
Line 1051... Line 1045...
1051
    g_iSectorVarID=Gv_GetVarIndex("sector");
1045
    g_iSectorVarID=Gv_GetVarIndex("sector");
1052
    g_iWallVarID=Gv_GetVarIndex("wall");
1046
    g_iWallVarID=Gv_GetVarIndex("wall");
1053
    g_iPlayerVarID=Gv_GetVarIndex("player");
1047
    g_iPlayerVarID=Gv_GetVarIndex("player");
1054
    g_iActorVarID=Gv_GetVarIndex("actorvar");
1048
    g_iActorVarID=Gv_GetVarIndex("actorvar");
1055
#endif
1049
#endif
-
 
1050
1056
    G_InitProjectileData();
1051
    for (i = 0; i <= MAXTILES - 1; i++)
-
 
1052
        Bmemcpy(&ProjectileData[i], &g_tile[i].defproj, sizeof(projectile_t));
1057
1053
1058
#ifndef LUNATIC
1054
#ifndef LUNATIC
1059
    // hackhackhackhackhack
1055
    // hackhackhackhackhack
1060
    i = hash_find(&h_arrays, "tilesizx");
1056
    if (i = hash_find(&h_arrays, "tilesizx"), i >= 0)
1061
    if (i >= 0)
-
 
1062
    {
1057
    {
1063
        int32_t j = 0;
-
 
1064
-
 
1065
        for (; j<MAXTILES; j++)
1058
        for (int j = 0; j < MAXTILES; j++)
1066
            aGameArrays[i].plValues[j] = tilesiz[j].x;
1059
            aGameArrays[i].plValues[j] = tilesiz[j].x;
1067
    }
1060
    }
1068
1061
1069
    i = hash_find(&h_arrays, "tilesizy");
1062
    if (i = hash_find(&h_arrays, "tilesizy"), i >= 0)
1070
    if (i >= 0)
-
 
1071
    {
1063
    {
1072
        int32_t j = 0;
-
 
1073
-
 
1074
        for (; j<MAXTILES; j++)
1064
        for (int j = 0; j < MAXTILES; j++)
1075
            aGameArrays[i].plValues[j] = tilesiz[j].y;
1065
            aGameArrays[i].plValues[j] = tilesiz[j].y;
1076
    }
1066
    }
1077
#endif
1067
#endif
1078
1068
1079
    //AddLog("EOF:ResetWeaponDefaults");
1069
    //AddLog("EOF:ResetWeaponDefaults");
Line 1197... Line 1187...
1197
    case SHOTSPARK1__STATIC: return SHOTSPARK1;
1187
    case SHOTSPARK1__STATIC: return SHOTSPARK1;
1198
    case SHRINKER__STATIC: return SHRINKER;
1188
    case SHRINKER__STATIC: return SHRINKER;
1199
    default: return tile;
1189
    default: return tile;
1200
    }
1190
    }
1201
}
1191
}
-
 
1192
1202
static int32_t G_StaticToDynamicSound(int32_t sound)
1193
static int32_t G_StaticToDynamicSound(int32_t sound)
1203
{
1194
{
1204
    switch (sound)
1195
    switch (sound)
1205
    {
1196
    {
1206
    case CAT_FIRE__STATIC: return CAT_FIRE;
1197
    case CAT_FIRE__STATIC: return CAT_FIRE;
Line 1467... Line 1458...
1467
1458
1468
#undef ADDWEAPONVAR
1459
#undef ADDWEAPONVAR
1469
1460
1470
void Gv_Init(void)
1461
void Gv_Init(void)
1471
{
1462
{
1472
    // only call ONCE
1463
    // already initialized
1473
-
 
1474
    // (... not true anymore)
1464
    if (aGameVars[0].dwFlags)
1475
    static int32_t inited=0;
-
 
1476
    if (inited)
-
 
1477
        return;
1465
        return;
1478
    inited = 1;
-
 
1479
1466
1480
#if !defined LUNATIC
1467
#if !defined LUNATIC
1481
    Gv_Clear();
1468
    Gv_Clear();
1482
#endif
1469
#endif
1483
    // Set up weapon defaults, g_playerWeapon[][].
1470
    // Set up weapon defaults, g_playerWeapon[][].