Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jushar committed May 1, 2017
1 parent 5478357 commit 89bd9b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
7 changes: 5 additions & 2 deletions LuaLibrary/MTADebug/MTADebug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ function MTATD.MTADebug:constructor(backend)
resource_path = self:_getResourceBasePath()
})

-- Wait a bit (so that the backend receives the breakpoints)
debugSleep(1000)

-- Initially fetch the breakpoints from the backend
-- and wait till they're received
self:_fetchBreakpoints(true)
Expand Down Expand Up @@ -142,7 +145,7 @@ end
-- Returns true if there is a breakpoint, false otherwise
-----------------------------------------------------------
function MTATD.MTADebug:hasBreakpoint(fileName, lineNumber)
local breakpoints = self._breakpoints[fileName]
local breakpoints = self._breakpoints[fileName:lower()]
if breakpoints then
return breakpoints[lineNumber]
end
Expand Down Expand Up @@ -232,7 +235,7 @@ function MTATD.MTADebug:_getResourceBasePath()

if triggerClientEvent then -- Is server?
local organizationalPath = getResourceOrganizationalPath(thisResource)
return getResourceName(thisResource).."/"..(organizationalPath ~= "" and organizationalPath.."/" or "")
return (organizationalPath ~= "" and organizationalPath.."/" or "")..getResourceName(thisResource).."/"
else
return getResourceName(thisResource).."/"
end
Expand Down
20 changes: 5 additions & 15 deletions VSCode_Extension/src/mtasaDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class MTASADebugSession extends DebugSession {
private _backendUrl: string = 'http://localhost:51237';

private _resourceName: string;
private _resourcesPath: string;
private _resourcePath: string;

private _isRunning: boolean = false;
Expand Down Expand Up @@ -123,6 +124,7 @@ class MTASADebugSession extends DebugSession {
}

this._resourceName = info.resource_name;
this._resourcesPath = normalize(`${args.serverpath}/mods/deathmatch/resources/`);
this._resourcePath = normalize(`${args.serverpath}/mods/deathmatch/resources/${info.resource_path}`);

// Start timer that polls for the execution being paused
Expand All @@ -138,7 +140,7 @@ class MTASADebugSession extends DebugSession {
// Clear interval as we successfully received the info
clearInterval(interval)
});
}, 500);
}, 200);
}

/**
Expand Down Expand Up @@ -221,7 +223,7 @@ class MTASADebugSession extends DebugSession {
const frames = new Array<StackFrame>();

// Only the current stack frame is supported for now
const currentFilePath = this.getAbsoluteResourcePath(this._currentFile);
const currentFilePath = this._resourcesPath + this._currentFile;
frames.push(new StackFrame(0, 'Frame 0', new Source(basename(currentFilePath),
this.convertDebuggerPathToClient(currentFilePath)),
this.convertDebuggerLineToClient(this._currentLine), 0));
Expand Down Expand Up @@ -383,19 +385,7 @@ class MTASADebugSession extends DebugSession {
private getRelativeResourcePath(absolutePath: string) {
const relativePath = normalize(absolutePath).toLowerCase().replace(this._resourcePath.toLowerCase(), '');

return relativePath.replace('\\', '/');
}

/**
* Returns the absolute path from a relative path
* @param relativePath The relative path (e.g. "<resourcenName>/server.lua")
* @return The absolute path
*/
private getAbsoluteResourcePath(relativePath: string) {
// Drop the resource name to prevent it from being in the string twice
relativePath = relativePath.replace(/(.*?)\/(.*)/, '$2');

return this._resourcePath + relativePath;
return relativePath.replace(/\\/g, '/');
}

private log(msg: string, line: number) {
Expand Down

0 comments on commit 89bd9b5

Please sign in to comment.