Skip to content

Instantly share code, notes, and snippets.

Alan Edwardes alanedwardes

View GitHub Profile
@alanedwardes
alanedwardes / Program.cs
Last active Jan 26, 2020
Parse the UE4 Vault API to catalogue it in a spreadsheet (exports the JSON -> CSV)
View Program.cs
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace UnrealVaultParser
{
class Program
{
View estranged-jenkinsfile-build-stamp.groovy
// Checkout and store away result
def checkoutResult = scm checkout
// Build a human readable build label
def buildLabel = [env.EstPlatform, checkoutResult.GIT_COMMIT.substring(0, 6), env.JOB_NAME, env.BUILD_NUMBER].join('-')
// Stamp the build config header file
def configFile = 'Depot/Source/EstCore/EstBuildConfig.h'
def buildConfig = readFile file: configFile
buildConfig += '\n#undef BUILD_COMMIT'
@alanedwardes
alanedwardes / EstScreenshotTaker.cpp
Created Dec 20, 2017
Unreal Engine 4 class to take and compress screenshots to a JPEG image, then raise an event with the compressed data.
View EstScreenshotTaker.cpp
// Estranged is a trade mark of Alan Edwardes.
#include "EstScreenshotTaker.h"
#include "IImageWrapper.h"
#include "IImageWrapperModule.h"
void UEstScreenshotTaker::RequestScreenshot()
{
if (GEngine == nullptr || GEngine->GameViewport == nullptr || bIsScreenshotRequested)
{
@alanedwardes
alanedwardes / EstPlayer.cpp
Last active Dec 19, 2017
A client-side smooth crouching implementation for Unreal Engine 4.
View EstPlayer.cpp
void AEstPlayer::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
UpdateCamera(DeltaSeconds);
}
void AEstPlayer::UpdateCamera(float DeltaSeconds)
{
FVector EyeLocation;
@alanedwardes
alanedwardes / s3_backup.sh
Last active Aug 29, 2015
Small script for backing up stuff on a linux server.
View s3_backup.sh
#!/bin/bash
# Get the day number
day="$(date +'%u')"
echo "Starting backup for day ${day}"
# Sync all data to S3, excluding git and svn folders
/usr/local/bin/aws s3 sync /path/to/folder s3://bucket/folder \
--exclude "*.svn*" --exclude "*.git*" --delete
@alanedwardes
alanedwardes / stringurlencode.c
Created Mar 14, 2014
Very simple C method to perform URL encoding on a char buffer. Includes a quick and dity list of characters to exclude. Some compilers will prefer sprintf_s or otherwise.
View stringurlencode.c
// ae - takes URL, puts percents in it.
void encodeUrl(char *out, int outSize, char *in, int inSize)
{
// Terminate our buffer
out[0] = '\0';
// Loop the input
for (int i = 0; i < inSize; i++)
{
// Get a char out of it
@alanedwardes
alanedwardes / logic_submerge.cpp
Created Jul 28, 2013
A Source Engine entity that fires an output when it's submerged.
View logic_submerge.cpp
//=============================================================================
//
// Purpose: Logic submerge - fires output when submerged in water.
//
//=============================================================================
#include "cbase.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@alanedwardes
alanedwardes / estranged_materialsystem.cpp
Created Jun 11, 2013
A passthru material system for the source engine. Doesn't work very well.
View estranged_materialsystem.cpp
#include "cbase.h"
#include "estranged_materialsystem.h"
#include "materialsystem\itexture.h"
#include "materialsystem/imaterialvar.h"
static void AppendShaderParams(const char* shader, IMaterial *pMat, KeyValues *newParams)
{
int nParams = pMat->ShaderParamCount();
IMaterialVar **pParams = pMat->GetShaderParams();
View passthru_materialsystem.hpp
//=============================================================================//
//
// Purpose: Implementation of IMaterialSystem interface which "passes tru" all
// function calls to the real interface. Can be used to override
// IMaterialSystem function calls (combined with engine->Mat_Stub).
//
//=============================================================================//
#ifndef MATERIALSYSTEM_PASSTHRU_H
#define MATERIALSYSTEM_PASSTHRU_H
@alanedwardes
alanedwardes / GetTimestamp.cpp
Created Nov 24, 2012
Get the Timestamp as a Char Array
View GetTimestamp.cpp
char* GetTimestamp()
{
time_t rawtime;
struct tm* timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
char* time = asctime(timeinfo);
char* newLine = strstr(time, "\n");
You can’t perform that action at this time.