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
  •  
  •  
  •  
29 changes: 29 additions & 0 deletions .github/workflows/Validate_File_Contents.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Validate file contents

on:
workflow_dispatch: # manual trigger

push:
paths:
- "plugin_*/**.h"
- "plugin_*/**.cpp"
- "shared/**.h"
- "shared/**.cpp"

pull_request:
paths:
- "plugin_*/**.h"
- "plugin_*/**.cpp"
- "shared/**.h"
- "shared/**.cpp"

jobs:
Validate_file_contents:
runs-on: ubuntu-latest

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

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

let result = true;
//result &= walkRecursive("./examples/");
result &= walkRecursive("./plugin_sa/");

console.log(result);
if (!result)
process.exit(1); // problem found


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)
{
if (filename.includes("/rw/")) // skip Renderware files
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;

result &= verifyPluginSdkComment(filename, headerExtensions.includes(filetype));

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_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::Found "${actualLines[i]}", expected "${expectedLines[i]}"`);
return false;
}
}

return true;
}
3 changes: 3 additions & 0 deletions .github/workflows/scripts/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cd ..\..\..
"D:\Program Files\Node\node.exe" ".github\workflows\scripts\Validate_File_Contents.js"
pause
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) source 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
1 change: 0 additions & 1 deletion hooking/Hooking.Patterns.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

#pragma once

#include <cassert>
#include <vector>
#include <string_view>
Expand Down
1 change: 0 additions & 1 deletion injector/gvm/translator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*
*/
#pragma once

#if !defined(INJECTOR_GVM_HAS_TRANSLATOR)
#error Missing INJECTOR_GVM_HAS_TRANSLATOR on compiler definitions
#endif
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CAudioManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#include "CAudioManager.h"

CAudioManager& AudioManager = *(CAudioManager*)0x5DCBC8;
1 change: 0 additions & 1 deletion plugin_II/game_II/CAudioManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#pragma once
#include "PluginBase.h"

Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CCar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#include "CCar.h"

void CCar::SetPosition(CEncodedVector pos) {
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CCar.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#pragma once
#include "PluginBase.h"
#include "CSprite.h"
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CCarManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#include "CCarManager.h"

CCarManager** gCarManager = (CCarManager**)0x5E4CA0;
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CCarManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#pragma once
#include "PluginBase.h"
#include "CCar.h"
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CFileMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#include "CFileMgr.h"

int CFileMgr::OpenFile(const char* name) {
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CFileMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#pragma once
#include "PluginBase.h"

Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#pragma once
#include "PluginBase.h"

Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#include "CGame.h"

CGame** gGame = (CGame**)0x5EB4FC;
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#pragma once
#include "PluginBase.h"

Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CKeybrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#include "CKeybrd.h"

CKeybrd** gKeybrd = (CKeybrd**)0x662128;
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CKeybrd.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#pragma once
#include "PluginBase.h"

Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CMenuManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#include "CMenuManager.h"

CMenuManager** FrontendMenuManager = (CMenuManager**)0x5EB160;
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CMenuManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#pragma once
#include "PluginBase.h"
#include "GBH.h"
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#include "CObject.h"

int const& CObject::GetPositionX(int* x) {
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CPed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#include "CPed.h"

void CPed::GiveWeapon(int id, int ammo) {
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CPed.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#pragma once
#include "PluginBase.h"
#include "CCar.h"
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CPedManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#include "CPedManager.h"

CPedManager** gPedManager = (CPedManager**)0x5E5BBC;
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CPedManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#pragma once
#include "PluginBase.h"

Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CPhysics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#include "CPhysics.h"
1 change: 0 additions & 1 deletion plugin_II/game_II/CPlayerPed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#include "CPlayerPed.h"
#include "CPed.h"

Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CPlayerPed.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#pragma once
#include "PluginBase.h"
#include "CPhysics.h"
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CPopulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#pragma once
#include "PluginBase.h"
#include "CCar.h"
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CRect.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Do not delete this comment block. Respect others' work!
*/
#pragma once

#include "PluginBase.h"

class CRect {
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#include "CReplay.h"

CReplay* gReplay = (CReplay*)0x5ECAC8;
Expand Down
1 change: 0 additions & 1 deletion plugin_II/game_II/CReplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
https://github.com/DK22Pac/plugin-sdk
Do not delete this comment block. Respect others' work!
*/

#pragma once
#include "PluginBase.h"

Expand Down
Loading
Loading