Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Southclaws committed Nov 2, 2020
2 parents 942006d + 0887379 commit 5d82a76
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 36 deletions.
1 change: 0 additions & 1 deletion BUILD_NUMBER

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
infomessage/messages/0=Welcome to the Scavenge and Survive test server!
infomessage/messages/1=Please report issues at github.com/Southclaws/ScavengeSurvive/issues
infomessage/messages/2=Official website: scavengesurvive.com
infomessage/messages/3=Join the project discord server! https://discord.gg/ffJ9WT
infomessage/messages/3=Join the project discord server! https://discord.gg/7y7mT4Q
player/allow-pause-map=0
player/combat-log-window=30
player/interior-entry=0
Expand Down
2 changes: 0 additions & 2 deletions gamemodes/sss/core/apparel/bandana.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

hook OnGameModeInit()
{
print("\n[OnGameModeInit] Initialising 'bandana'...");

new tmp;

tmp = DefineMaskItem(item_BandanaBlue);
Expand Down
3 changes: 1 addition & 2 deletions gamemodes/sss/core/itemtype/backpack.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,7 @@ hook OnItemCreate(Item:itemid)

if(lootindex != -1)
{
if(!IsValidContainer(containerid))
FillContainerWithLoot(containerid, random(4), lootindex);
FillContainerWithLoot(containerid, random(4), lootindex);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gamemodes/sss/core/itemtype/liquid-container.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ hook OnItemNameRender(Item:itemid, ItemType:itemtype)
}
}

hook OnPlayerUseItemWithBtn(playerid, Button:buttonid, Item:itemid)
hook OnPlayerUseItemWithItem(playerid, Item:itemid, Item:withitemid)
{
if(liq_ItemTypeLiquidContainer[GetItemType(itemid)] != INVALID_LIQUID_CONTAINER)
{
Expand Down
4 changes: 3 additions & 1 deletion gamemodes/sss/core/player/accounts.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,11 @@ DisplayRegisterPrompt(playerid)
new Error:e = CreateAccount(playerid, buffer);
if(IsError(e))
{
new cause[128];
GetLastErrorCause(cause);
Logger_Err("failed to create account for player",
Logger_P(playerid),
Logger_E(e)
Logger_S("cause", cause)
);
Handled();
return 1;
Expand Down
4 changes: 3 additions & 1 deletion gamemodes/sss/core/player/player.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ timer LoadAccountDelay[5000](playerid)
new Error:e = LoadAccount(playerid);
if(IsError(e)) // LoadAccount aborted, kick player.
{
new cause[128];
GetLastErrorCause(cause);
Logger_Err("failed to load account",
Logger_P(playerid),
Logger_E(e));
Logger_S("cause", cause));
KickPlayer(playerid, "Account load failed");
Handled();
return;
Expand Down
2 changes: 1 addition & 1 deletion gamemodes/sss/core/server/init.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ public OnScriptInit()
DefineItemTypeAmmo(item_Ammo556, "FMJ", calibre_556, 1.1, 1.2, 0.8, 30);
DefineItemTypeAmmo(item_Ammo357, "FMJ", calibre_357, 1.2, 1.1, 0.9, 10);
DefineItemTypeAmmo(item_AmmoRocket, "RPG", calibre_rpg, 1.0, 1.0, 1.0, 1);
DefineItemTypeAmmo(item_GasCan, "Petrol", calibre_fuel, 0.0, 0.0, 0.0, 20);
DefineItemTypeAmmo(item_GasCan, "Petrol", calibre_fuel, 0.0, 0.0, 0.0, 20, true);
DefineItemTypeAmmo(item_Ammo9mmFMJ, "FMJ", calibre_9mm, 1.2, 0.5, 0.8, 20);
DefineItemTypeAmmo(item_AmmoFlechette, "Flechette", calibre_12g, 1.6, 0.6, 0.2, 8);
DefineItemTypeAmmo(item_AmmoHomeBuck, "Improvised", calibre_12g, 1.6, 0.4, 0.3, 14);
Expand Down
2 changes: 1 addition & 1 deletion gamemodes/sss/core/vehicle/loot-vehicle.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ GenerateVehicleData(vehicleid)

// Putting loot in trunks

if(lootindex != -1 && 0 < trunksize <= MAX_INVENTORY_SLOTS)
if(lootindex != -1 && 0 < trunksize <= MAX_CONTAINER_SLOTS)
{
FillContainerWithLoot(GetVehicleContainer(vehicleid), random(trunksize / 3), lootindex);
}
Expand Down
26 changes: 24 additions & 2 deletions gamemodes/sss/core/weapon/ammunition.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ ItemType: ammo_itemType,
Float: ammo_bleedrateMult,
Float: ammo_knockoutMult,
Float: ammo_penetration,
ammo_size
ammo_size,
ammo_notransfer
}


Expand Down Expand Up @@ -64,7 +65,7 @@ stock DefineAmmoCalibre(const name[], Float:bleedrate)
return clbr_Total++;
}

stock DefineItemTypeAmmo(ItemType:itemtype, const name[], calibre, Float:bleedratemult, Float:knockoutmult, Float:penetration, size)
stock DefineItemTypeAmmo(ItemType:itemtype, const name[], calibre, Float:bleedratemult, Float:knockoutmult, Float:penetration, size, bool:notransfer = false)
{
SetItemTypeMaxArrayData(itemtype, 1);

Expand All @@ -75,6 +76,7 @@ stock DefineItemTypeAmmo(ItemType:itemtype, const name[], calibre, Float:bleedra
ammo_Data[ammo_Total][ammo_knockoutMult] = knockoutmult;
ammo_Data[ammo_Total][ammo_penetration] = penetration;
ammo_Data[ammo_Total][ammo_size] = size;
ammo_Data[ammo_Total][ammo_notransfer] = notransfer;

ammo_ItemTypeAmmoType[itemtype] = ammo_Total;

Expand Down Expand Up @@ -226,6 +228,15 @@ stock GetAmmoTypeSize(ammotype)
return ammo_Data[ammotype][ammo_size];
}

// ammo_notransfer
stock IsAmmoTypeNoTransfer(ammotype)
{
if(!(0 <= ammotype < ammo_Total))
return 0;

return ammo_Data[ammotype][ammo_notransfer];
}


stock GetItemTypeAmmoType(ItemType:itemtype)
{
Expand Down Expand Up @@ -257,6 +268,17 @@ stock GetItemTypeMagSize(ItemType:itemtype)
return ammo_Data[ammo_ItemTypeAmmoType[itemtype]][ammo_size];
}

stock IsItemTypeAmmoTypeNoTransfer(ammotype)
{
if(!IsValidItemType(itemtype))
return -1;

if(ammo_ItemTypeAmmoType[itemtype] == -1)
return -1;

return ammo_Data[ammo_ItemTypeAmmoType[itemtype]][ammo_notransfer];
}

stock GetAmmoItemTypesOfCalibre(calibre, ItemType:output[], max = sizeof(output))
{
new idx;
Expand Down
6 changes: 3 additions & 3 deletions gamemodes/sss/core/weapon/interact.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ _PickUpAmmoTransferCheck(playerid, Item:helditemid, Item:ammoitemid)

ammotypeid = GetItemTypeAmmoType(ammoitemtype);

if(ammotypeid != -1) // Transfer ammo from ammo item to held weapon
if(ammotypeid != -1 && !IsAmmoTypeNoTransfer(ammotypeid)) // Transfer ammo from ammo item to held weapon
{
new heldcalibre = GetItemWeaponCalibre(heldtypeid);

Expand Down Expand Up @@ -166,7 +166,7 @@ _PickUpAmmoTransferCheck(playerid, Item:helditemid, Item:ammoitemid)

heldtypeid = GetItemTypeAmmoType(helditemtype);

if(heldtypeid != -1) // Player is holding an ammo item
if(heldtypeid != -1 && !IsAmmoTypeNoTransfer(heldtypeid)) // Player is holding an ammo item
{
new ammotypeid = GetItemTypeWeapon(ammoitemtype);

Expand Down Expand Up @@ -205,7 +205,7 @@ _PickUpAmmoTransferCheck(playerid, Item:helditemid, Item:ammoitemid)

ammotypeid = GetItemTypeAmmoType(ammoitemtype);

if(ammotypeid != -1) // Transfer ammo from ammo item to held ammo item
if(ammotypeid != -1 && !IsAmmoTypeNoTransfer(ammotypeid)) // Transfer ammo from ammo item to held ammo item
{
/*if(GetItemExtraData(helditemid) == 0)
{
Expand Down
1 change: 0 additions & 1 deletion gamemodes/sss/core/world/loot.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ stock FillContainerWithLoot(Container:containerid, slots, lootindex)
return -1;
}

// log("[FillContainerWithLoot] containerid %d, slots %d, lootindex %d", containerid, slots, lootindex);
new containersize;
GetContainerSize(containerid, containersize);

Expand Down
1 change: 0 additions & 1 deletion runner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ type Config struct {
Settings string `envconfig:"SETTINGS_OVERRIDE"`
Restart time.Duration `envconfig:"AUTO_RESTART_TIME" default:"1h"`
AutoBuild bool `envconfig:"AUTO_BUILD" default:"false"`
BuildFile string `envconfig:"BUILD_FILE" default:""`
DiscordToken string `envconfig:"DISCORD_TOKEN" default:""`
DiscordChannel string `envconfig:"DISCORD_CHANNEL" default:""`
RconPassword string `envconfig:"RCON_PASSWORD" default:"scavenge"`
Expand Down
5 changes: 0 additions & 5 deletions runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,14 @@ func Run(cfg Config) error {
return errors.Wrap(err, "failed to interpret directory as Pawn package")
}

// pcx.Runtime = runtimeName
pcx.CacheDir = cacheDir
// pcx.BuildName = build
pcx.ForceBuild = forceBuild
pcx.ForceEnsure = forceEnsure
pcx.BuildFile = cfg.BuildFile
pcx.Relative = true
if cfg.RconPassword != "" {
pcx.Package.Runtime.RCONPassword = &cfg.RconPassword
}

zap.L().Debug("preparing runtime environment", zap.String("buildfile", pcx.BuildFile))

if err := pcx.RunPrepare(context.Background()); err != nil {
return errors.Wrap(err, "failed to prepare runtime")
}
Expand Down
54 changes: 41 additions & 13 deletions runner/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"go.uber.org/zap"
)

func RunWatcher(ctx context.Context, pcx *pkgcontext.PackageContext) {
func RunWatcher(parent context.Context, pcx *pkgcontext.PackageContext) {
zap.L().Info("starting file watcher for auto rebuild")

w, err := fsnotify.NewWatcher()
Expand All @@ -34,36 +34,64 @@ func RunWatcher(ctx context.Context, pcx *pkgcontext.PackageContext) {
panic(err)
}

var ctx context.Context
var cancel context.CancelFunc
defer func() {
if cancel != nil {
cancel()
}
}()
builds := make(chan error)
running := false
last := time.Time{}

for {
select {
case e := <-w.Events:
if time.Since(last) < time.Second*10 {
zap.L().Debug("ignoring frequent change", zap.Duration("since", time.Since(last)))
if time.Since(last) < time.Second {
continue
}

zap.L().Debug("source code change", zap.String("event", e.String()))
if running {
zap.L().Debug("cancelling existing build job")
cancel()
}

fmt.Print("\n")
zap.L().Debug("source code change", zap.String("event", e.String()))

ctx, cancel = context.WithCancel(parent)
running = true
last = time.Now()
_, _, err := pcx.Build(ctx, "", false, false, false, "BUILD_NUMBER")

go doBuild(ctx, pcx, builds)

case err := <-builds:
if err != nil {
zap.L().Info("build failed", zap.Error(err))
continue
} else {
zap.L().Info("build finished", zap.Duration("duration", time.Since(last)))
}

fmt.Print("\n")

zap.L().Info("build finished", zap.Duration("duration", time.Since(last)))
running = false

case e := <-w.Errors:
zap.L().Info("watcher error", zap.Error(e))

case <-ctx.Done():
case <-parent.Done():
if cancel != nil {
cancel()
}
return
}
}
}

func doBuild(ctx context.Context, pcx *pkgcontext.PackageContext, results chan error) {
fmt.Print("\n") // output padding, for readability of build errors etc.
_, _, err := pcx.Build(ctx, "", false, false, false, "")
if err != nil {
zap.L().Info("build failed", zap.Error(err))
results <- err
}
fmt.Print("\n")

results <- nil
}

1 comment on commit 5d82a76

@vercel
Copy link

@vercel vercel bot commented on 5d82a76 Nov 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.