Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
36 changes: 36 additions & 0 deletions .github/workflows/Validate_File_Contents.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Validate contents

on:
workflow_dispatch: # manual trigger

push:
paths:
- "examples/**/*.h*"
- "examples/**/*.c*"
- "plugin_*/**/*.c*"
- "plugin_*/**/*.h*"
- "plugin_*/**/*.c*"
- "shared/**/*.h*"
- "shared/**/*.c*"

pull_request:
paths:
- "examples/**/*.h*"
- "examples/**/*.c*"
- "plugin_*/**/*.c*"
- "plugin_*/**/*.h*"
- "plugin_*/**/*.c*"
- "shared/**/*.h*"
- "shared/**/*.c*"

jobs:
Validate_contents:
name: Validate contents
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Check files
run: node .github/workflows/scripts/Validate_Contents.js
122 changes: 122 additions & 0 deletions .github/workflows/scripts/Validate_Contents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
const fs = require("fs");
const path = require("path");

let result = true;
result &= walkRecursive("./examples/");
result &= walkRecursive("./plugin_II/");
result &= walkRecursive("./plugin_III/");
result &= walkRecursive("./plugin_vc/");
result &= walkRecursive("./plugin_sa/");
result &= walkRecursive("./plugin_IV/");
result &= walkRecursive("./plugin_iii_unreal/");
result &= walkRecursive("./plugin_vc_unreal/");
result &= walkRecursive("./plugin_sa_unreal/");
result &= walkRecursive("./shared/");

if (!result)
process.exit(1); // report workflow failed


function walkRecursive(dir)
{
let result = true;

const files = fs.readdirSync(dir, { withFileTypes: true });
for (const file of files)
{
let filename = path.join(dir, file.name);
filename = filename.split(path.sep).join('/');

if (file.isDirectory())
result &= walkRecursive(filename);
else
result &= processFile(filename);
}

return result;
}

function processFile(filename)
{
let result = true;

result &= processCodeFile(filename);

return result;
}

function processCodeFile(filename)
{
// skip files
if (filename.includes("/bass/") ||
filename.includes("/d3d/") ||
filename.includes("/dxsdk/") ||
filename.includes("/resource.h") ||
filename.includes("/rw/") ||
filename.includes("/rwd3d9/") ||
filename.includes("/stdafx.h") ||
filename.includes("/stdafx.cpp"))
return true;

const headerExtensions = [".h", ".hpp"];
const sourceExtensions = [".c", ".cpp"];
const filetype = path.extname(filename).toLowerCase();

if (!headerExtensions.includes(filetype) && !sourceExtensions.includes(filetype))
return true; // not code file

let result = true;

if (!filename.startsWith("examples/")) result &= verifyPluginSdkComment(filename, headerExtensions.includes(filetype)); // check comment header

return result;
}

function verifyPluginSdkComment(filename, isHeader)
{
let expected = "/*\n";

expected += " Plugin-SDK (Grand Theft Auto";
if (filename.toLowerCase().startsWith("plugin_ii/")) expected += " 2)";
if (filename.toLowerCase().startsWith("plugin_iii/")) expected += " 3)";
if (filename.toLowerCase().startsWith("plugin_vc/")) expected += " Vice City)";
if (filename.toLowerCase().startsWith("plugin_sa/")) expected += " San Andreas)";
if (filename.toLowerCase().startsWith("plugin_iv/")) expected += " IV)";
if (filename.toLowerCase().startsWith("plugin_iii_unreal/")) expected += " 3 Unreal)";
if (filename.toLowerCase().startsWith("plugin_vc_unreal/")) expected += " Vice City Unreal)";
if (filename.toLowerCase().startsWith("plugin_sa_unreal/")) expected += " San Andreas Unreal)";
if (filename.toLowerCase().startsWith("shared/")) expected += ") SHARED";
expected += " "

if (isHeader)
expected += "header";
else
expected += "source";
expected += " file\n";

expected += " Authors: GTA Community. See more here\n";
expected += " https://github.com/DK22Pac/plugin-sdk\n";
expected += " Do not delete this comment block. Respect others' work!\n";
expected += "*/";

const buffer = Buffer.alloc(expected.length + 100);
const fd = fs.openSync(filename, 'r');
fs.readSync(fd, buffer, 0, expected.length + 100, 0);
fs.closeSync(fd);
let actual = buffer.toString('utf8');
actual = actual.replace(/\r\n/g, "\n");

// compare lines
const actualLines = actual.split('\n');
const expectedLines = expected.split('\n');
for (let i = 0; i < expectedLines.length; i++)
{
if (actualLines[i] !== expectedLines[i])
{
console.log(`::error file=${filename},line=${i+1},title=Invalid PSDK comment header::Expected "${expectedLines[i]}", found "${actualLines[i]}"`);
return false;
}
}

return true;
}
8 changes: 4 additions & 4 deletions examples/Neon/KeyCheck.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
Plugin-SDK (Grand Theft Auto) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
Plugin-SDK (Grand Theft Auto) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#include "KeyCheck.h"
#include "plugin.h"
Expand Down
8 changes: 4 additions & 4 deletions examples/Neon/KeyCheck.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
Plugin-SDK (Grand Theft Auto) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
Plugin-SDK (Grand Theft Auto) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion plugin_II/game_II/CPopulation.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Plugin-SDK (Grand Theft Auto 2) header file
Plugin-SDK (Grand Theft Auto 2) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
Expand Down
6 changes: 6 additions & 0 deletions plugin_II/game_II/tImage.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Plugin-SDK (Grand Theft Auto 2) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#pragma once

struct tImage {
Expand Down
6 changes: 6 additions & 0 deletions plugin_II/game_II/tLight.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Plugin-SDK (Grand Theft Auto 2) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#pragma once

struct tLight {
Expand Down
6 changes: 6 additions & 0 deletions plugin_II/game_II/tVertex.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Plugin-SDK (Grand Theft Auto 2) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#pragma once

struct tVertex {
Expand Down
8 changes: 4 additions & 4 deletions plugin_III/game_III/CAutoPilot.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
Plugin-SDK (Grand Theft Auto 3) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
Plugin-SDK (Grand Theft Auto 3) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#include "CAutoPilot.h"

Expand Down
9 changes: 4 additions & 5 deletions plugin_III/game_III/CAutoPilot.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/*
Plugin-SDK (Grand Theft Auto 3) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
Plugin-SDK (Grand Theft Auto 3) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#pragma once

#include "PluginBase.h"
#include "CPathFind.h"
#include "eCarMission.h"
Expand Down
8 changes: 4 additions & 4 deletions plugin_III/game_III/CControllerConfigManager.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
Plugin-SDK (Grand Theft Auto 3) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
Plugin-SDK (Grand Theft Auto 3) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#include "CControllerConfigManager.h"

Expand Down
8 changes: 4 additions & 4 deletions plugin_III/game_III/CControllerConfigManager.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
Plugin-SDK (Grand Theft Auto 3) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
Plugin-SDK (Grand Theft Auto 3) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#pragma once
#include "PluginBase.h"
Expand Down
8 changes: 4 additions & 4 deletions plugin_III/game_III/CControllerState.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
Plugin-SDK (Grand Theft Auto 3) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
Plugin-SDK (Grand Theft Auto 3) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#include "CControllerState.h"

Expand Down
9 changes: 4 additions & 5 deletions plugin_III/game_III/CControllerState.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/*
Plugin-SDK (Grand Theft Auto 3) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
Plugin-SDK (Grand Theft Auto 3) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#pragma once

#include "PluginBase.h"

class CControllerState {
Expand Down
9 changes: 4 additions & 5 deletions plugin_III/game_III/CFileLoader.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/*
Plugin-SDK (Grand Theft Auto 3) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
Plugin-SDK (Grand Theft Auto 3) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#pragma once

#include "PluginBase.h"
#include "RenderWare.h"
#include "CColModel.h"
Expand Down
8 changes: 4 additions & 4 deletions plugin_III/game_III/CFontDetails.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
Plugin-SDK (Grand Theft Auto 3) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
Plugin-SDK (Grand Theft Auto 3) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#include "CFontDetails.h"

Expand Down
9 changes: 4 additions & 5 deletions plugin_III/game_III/CFontDetails.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/*
Plugin-SDK (Grand Theft Auto 3) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
Plugin-SDK (Grand Theft Auto 3) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#pragma once

#include "PluginBase.h"
#include "CRGBA.h"
#include "CVector2D.h"
Expand Down
8 changes: 4 additions & 4 deletions plugin_III/game_III/CHud.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
Plugin-SDK (Grand Theft Auto 3) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
Plugin-SDK (Grand Theft Auto 3) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#include "CHud.h"

Expand Down
10 changes: 5 additions & 5 deletions plugin_III/game_III/CHud.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once
/*
Plugin-SDK (Grand Theft Auto 3) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
Plugin-SDK (Grand Theft Auto 3) header file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#pragma once
#include "PluginBase.h"
#include "CSprite2d.h"

Expand Down
8 changes: 4 additions & 4 deletions plugin_III/game_III/CKeyboardState.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
Plugin-SDK (Grand Theft Auto 3) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
Plugin-SDK (Grand Theft Auto 3) source file
Authors: GTA Community. See more here
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/
#include "CKeyboardState.h"

Expand Down
Loading